I am having problems with some code I have used several times before with no problems.
Here is a cut down test version of the code
$filterResult = "top cat";
$gameId = "myGame";
$score = 10;
$sql = "insert into highScores(name,score, gameId) values ('$filterResult','$score','$gameId')";
$result = mysql_query($sql) or die("Didnt work");
Any ideas why this wouldn’t work? I am getting the “Didnt work” text appearing in the browser when I test it.
It is baffling me!!
No error handling Paul?
$result = mysql_query($sql) or die("Didnt work because... " . mysql_error());
Thanks Anthony - can’t believe I haven’t come across that mysql_error function before. I tried adding code to my php5.ini file to display errors but that did no good.
Anyway thanks to your help I have now discovered it was due to me being a muppet as the table is called “highscores” and not “highScores” - doh!!
I’d suggest it this way
$result = mysql_query($sql) or trigger_error(mysql_error()." in ".$sql);
it will add query itself to the error message which can be very useful, and also will handle mysql errors the same way as PHP ones. and no instant death of the script so you can close it correctly
Yeah too right Anthony! About time you became a full-time PHP Ninja:)
Cheers - Shrapnel, I will give that a try. Many thanks