Whats wrong with this?

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



<?php

	require_once ('game_mysql_connect.php'); 

	$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");

	echo "welcomeMessage=success";

?>


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!!

Thanks
Paul

No error handling Paul? :stuck_out_tongue:

[fphp]mysql_error/fphp.


$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!!

Cheers

Paul

Ha.

Ain’t it always the way!

Glad it’s sorted Paul. :smiley:

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