- Forums
- MySQL
- Mysql Help - How To Display Or Show MYSQL Query Errors Results PHP Scripts
mysql is fun and now i am going to demostrate how to display or show mysql query erros wiht your php code. i will give you the php code you need to use for display the error from the mysql server [874], Last Updated: Sat May 18, 2024
wallpaperama
Wed Apr 04, 2007
1 Comments
2042 Visits
ok, today i was running a script to insert some data into my mysql database, i kept running the script but it just wouldn't insert the data i was entering on my HTML form through my PHP Script. Then I remember that you can actually display MYSQL errors with the
mysql_error() fucntion in php.
this was my query how it looked like:
CODE:
$sql = "INSERT INTO my_table(this and,this) values ('$this','$and','$this')";
$result = mysql_query($sql ,$database);
i kept looking at my query to see if there were any errors, but i didn't catch anything wrong.
So i finally had to do something, i put the
mysql_error() to display (or show) if there were any errros on my MYSQL query. so i changed the code to this:
CODE:
$sql = "INSERT INTO my_table(this and,this) values ('$this','$and','$this')";
if($result = mysql_query($sql))
{
echo "<h1>SUCESS</h1>";
}
else
{
echo "ERROR: ".mysql_error()."<BR>";
}
so now when i ran my script, i got it to display the error, and this is what it said:
CODE:
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and, thisp at line 3
GOTCHA!! did you see my mistake? if you notice on my $sql after
my_table(this i need to put a comma after "this" so this is how my $sql shoule look like:
CODE:
$sql = "INSERT INTO my_table(this,and,this) values ('$this','$and','$this')";
$result = mysql_query($sql ,$database);
After I corrected this, the script was able to insert all the data from my from into mysql database.
i know that is possible. but i dont find com.sqlserver.jdbc.driver. can you help me?
thnaks
kisses
https://www.wallpaperama.com/forums/mysql-help-hot-to-display-or-show-mysql-query-errors-results-php-scripts-t1028.html