Crew-Portal Posted August 27, 2007 Share Posted August 27, 2007 Hi its me again. Sorry for posting so much its just that I am on a time limit to get these things done: I keep getting this error: A fatal MySQL error occured. Query: Error: (1064) 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 'WHERE username=999' at line 1 on my script. It calls another script that makes the data get posted in the SQL database. Everything is getting posted except for this on line of code: <?php <?php $connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect."); $db = @mysql_select_db($db_name, $connection) or die("Couldn't select database."); $sqlrand="SELECT * FROM aircraft WHERE aircraft = \"$_POST[aircraft]\""; $result = @mysql_query($sqlrand,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); $num=mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $passengersrand = rand($row['min_pass'], $row['max_pass']); $cargorand = rand($row['min_carg'], $row['max_carg']); } $sqlrand1="UPDATE user SET pax=$passengersrand WHERE username=$valid_user"; $result = @mysql_query($sqlrand1,$connection) or die("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error()); ?> ?> basically it takes a random number that is stated in mysql and makes it random. There are 2 tables one for hightest and one for lowest of each type. Thank you in advance and thank you for putting up with me. Link to comment https://forums.phpfreaks.com/topic/66853-another-mysql-error/ Share on other sites More sharing options...
Barand Posted August 27, 2007 Share Posted August 27, 2007 It's a lot easier to spot syntax errors if we can see the actual query being executed. What does this output? echo $sqlrand1; Link to comment https://forums.phpfreaks.com/topic/66853-another-mysql-error/#findComment-335130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.