• Register
0 votes
510 views

Problem :

 I am facing below error :

Fatal error: Uncaught Error: Call to undefined function mysql_escape_string() in D:\xampp\htdocs\phoenixproject\register.php:16 Stack trace: #0 {main} thrown in D:\xampp\htdocs\phoenixproject\register.php on line 16

Well I know one thing that I am trying to mix the mysql and mysqli.

Still how can I fix above issue ?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You will need the "config.php" it should contain the below things:

$link = mysqli_connect("localhost", "username", "mpassword", "database") or die($link);

Then please change the escape functions to use your mysqli_ version of it and pass the connection parameter correctly to it as shown below:

$myname = mysqli_real_escape_string($link, $_POST['myname']);

$mylname = mysqli_real_escape_string($link, $_POST['mylname']);

$myuname = mysqli_real_escape_string($link, $_POST[my'uname']);

$myemail1 = mysqli_real_escape_string($link, $myemail1);

$myemail2 = mysqli_real_escape_string($link, $myemail2);

$mypass1 = mysqli_real_escape_string($link, $mypass1);

$mypass2 = mysqli_real_escape_string($link, $mypass2);

For your query, try to use your i version and try passing the connection to it as the very first parameter as shown below :

mysqli_query($link, "INSERT INTO ...

Also please check for errors on your query using the mysqli_error($link);

It will help you in modifying the query to read as below :

$query = mysqli_query($link, "INSERT INTO ...

and also doing as below

if(!$query){

   echo "My Error: " . mysqli_error($link);

   }

Also please try to read the following in regards to the API mixing :

Finally “Can I mix the MySQL APIs in the PHP?”

The answer is you can not. As the mysql_ with mysqli_ or PDO etc. Please do NOT intermix them together.

9 7 4
38,600 points

Related questions

0 votes
1 answer 101 views
0 votes
1 answer 20 views
0 votes
1 answer 19 views
19 views
What i am attempting to make a easy connection with XAMPP and MySQL server, however whenever I attempt to enter data or connect to the database, i obtain this error. Why this is happen and how to solve it?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 194 views
194 views
can someone help me why i am seeing “PHP Fatal error: Uncaught Error: Call to undefined function mysql_query() in /Applications/MAMP/htdocs/lprapp/config.php:23 Stack trace:#0 {main} thrown in /Applications/MAMP/htdocs/lprapp/config.php on line 23&rdquo” this error and how to resolve it.
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 119 views
119 views
Problem : I have set it up PHP, MySQL, and Apache. localhost() for PHP and everything is working very well. But after I downloaded the MySQL, it reports below error: “Fatal error: Call to undefined function mysql_connect()” How can I fix this Fatal Error?
asked Jan 29, 2020 jwilliam 3.9k points
0 votes
1 answer 51 views
0 votes
1 answer 28 views
28 views
Problem : uncaught error: call to a member function bind_param() on boolean
asked Feb 14 Shovo210 3.9k points
0 votes
1 answer 22 views
22 views
Problem : fatal error: call to undefined function curl_init()
asked Feb 14 Shovo210 3.9k points
0 votes
1 answer 68 views
68 views
Problem: My code gives error when i execute the file. i need someone to fix the error for me. if (isset($file_root)) { if (!empty(trim($file_root))) { //Error Line echo "test"; } }
asked Nov 5, 2020 prog_learner 2.5k points
0 votes
1 answer 520 views
520 views
Problem : I am new to PHP. When I am trying to execute my PHP code then I am facing below error ( ! ) Fatal error: Cannot use isset() on the result of a function call (you can use "null !== func()" instead) in C:\Users\ mphil\Documents\NetBeansProjects\ ... 45 Call Stack #   Time    Memory  Function    Location 1   0.0000  234208  {main}( )   ..\index.php:0 Please help me in fixing this issue.
asked Feb 15, 2020 mphil 2.3k points