• Register
0 votes
162 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

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 9 views
9 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 Daniel Anderson 4k points
0 votes
1 answer 31 views
31 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 Daniel Anderson 4k points
0 votes
1 answer 74 views
74 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 jwilliam 3.9k points