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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.