Jump to content

another MySQL error


Crew-Portal

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.