Jump to content

Mysql_error()


morrisjohnny

Recommended Posts

I've tried rearranging the mysql_query so theirs '' around the feild names and values, if i remove the ' from around the feild names it says near ....'From,To)VALUES(`1`,`111.1.1.1`,`127.0.0.1`' ....Any suggestions it normally works with other scripts i've created. this one just seems to be throwing meLine Causing Error Bottom of post for full code

<?phpsession_start();include"Connections/main.php";$gcmd=explode(":",$_GET['q']);if($gcmd[0]=="/clear"){	$_SESSION['cmdhis']='';}else if($gcmd[0]=="/help"){	$_SESSION['cmdhis']='Available Commandsrun:"Program Location"		Run Programconnect:"Server Address"	Connect To Serverdisconnect:			Disconnect From Server/clear				Clear Command Window/help				Activate Help Window';}else if($gcmd[0]=="disconnect"){	if(isset($_SESSION['connectedto']))	{	mysql_query("DELETE * FROM $tbl_bounces WHERE UID='{$_SESSION[iD]}'");	unset($_SESSION['connectedto']);	$_SESSION['cmdhis']='Disconnected'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}	else	{		$_SESSION['cmdhis']='No Active Connection'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}}else if($gcmd[0]=="connect"){	if($_SESSION['connectedto']=="")	{	$gconnect=mysql_query("SELECT * FROM $tbl_servers WHERE Server_IP='".$gcmd['1']."'");	$gconnect2=mysql_query("SELECT * FROM $tbl_computers WHERE IP='".$gcmd['1']."'");	if (mysql_num_rows($gconnect)>0)	{		$_SESSION['connectedto']=$gcmd[1];		$display=$_SESSION['connectedto'];		$_SESSION['cmdhis']='Connection To '.$gcmd[1].' Successful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}	else if(mysql_num_rows($gconnect2)>0)	{		$_SESSION['connectedto']=$gcmd[1];		$_SESSION['cmdhis']='Connection To '.$gcmd[1].' Successful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}	else {echo $_SESSION['cmdhis']='Connection To '.$gcmd[1].' Unsuccessful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];}	//End OF Test	$connectedto=$gcmd[1];	}	else	{		if($_SESSION['connectedto']==$gcmd[1])		{$_SESSION['cmdhis']='Unable To Bounce To/From Same LocationBouncing From:'.$_SESSION['connectedto'].' To:'.$gcmd[1].''.$_SESSION['cmdhis'];}		else		{		//START TEMP		$gconnect=mysql_query("SELECT * FROM $tbl_servers WHERE Server_IP='".$gcmd['1']."'");		$gconnect2=mysql_query("SELECT * FROM $tbl_computers WHERE IP='".$gcmd['1']."'");		if (mysql_num_rows($gconnect)>0)		{			$valid=1;		}		else if(mysql_num_rows($gconnect2)>0)		{			$valid=1;		}		if($valid==1)		{			$display=$_SESSION['connectedto'];			$_SESSION['cmdhis']='Connection To '.$gcmd[1].' Successful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];			$current=$_SESSION['connectedto'];			$new=$gcmd[1];			mysql_query("INSERT INTO $tbl_bounces (UID,`From`,`To`)VALUES(`{$_SESSION[iD]}`,`{$current}`,`{$new}`");			$_SESSION['connectedto']=$gcmd[1];			echo mysql_error();		}		else		{		echo $_SESSION['cmdhis']='Connection To '.$gcmd[1].' Unsuccessful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];		}		//END TEMP		}	}}else if($gcmd[0]==" "){	$_SESSION['cmdhis']=''.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];}else{	$_SESSION['cmdhis']='Unknown Command'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];}echo '<textarea rows="6" readonly=\"readonly\" width="100%" class="windowtext" name="cmdhis" scrolling="no">'.$_SESSION['cmdhis'].'</textarea>';if(isset($_SESSION['connectedto'])){echo'<br />Connected:'.$_SESSION['connectedto'];}else{echo'<br />No Connection';}?>

Link to comment
Share on other sites

I've tried rearranging the mysql_query so theirs '' around the feild names and values, if i remove the ' from around the feild names it says near ....'From,To)VALUES(`1`,`111.1.1.1`,`127.0.0.1`' ....Any suggestions it normally works with other scripts i've created. this one just seems to be throwing meLine Causing Error Bottom of post for full code
<?phpsession_start();include"Connections/main.php";$gcmd=explode(":",$_GET['q']);if($gcmd[0]=="/clear"){	$_SESSION['cmdhis']='';}else if($gcmd[0]=="/help"){	$_SESSION['cmdhis']='Available Commandsrun:"Program Location"		Run Programconnect:"Server Address"	Connect To Serverdisconnect:			Disconnect From Server/clear				Clear Command Window/help				Activate Help Window';}else if($gcmd[0]=="disconnect"){	if(isset($_SESSION['connectedto']))	{	mysql_query("DELETE * FROM $tbl_bounces WHERE UID='{$_SESSION[iD]}'");	unset($_SESSION['connectedto']);	$_SESSION['cmdhis']='Disconnected'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}	else	{		$_SESSION['cmdhis']='No Active Connection'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}}else if($gcmd[0]=="connect"){	if($_SESSION['connectedto']=="")	{	$gconnect=mysql_query("SELECT * FROM $tbl_servers WHERE Server_IP='".$gcmd['1']."'");	$gconnect2=mysql_query("SELECT * FROM $tbl_computers WHERE IP='".$gcmd['1']."'");	if (mysql_num_rows($gconnect)>0)	{		$_SESSION['connectedto']=$gcmd[1];		$display=$_SESSION['connectedto'];		$_SESSION['cmdhis']='Connection To '.$gcmd[1].' Successful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}	else if(mysql_num_rows($gconnect2)>0)	{		$_SESSION['connectedto']=$gcmd[1];		$_SESSION['cmdhis']='Connection To '.$gcmd[1].' Successful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];	}	else {echo $_SESSION['cmdhis']='Connection To '.$gcmd[1].' Unsuccessful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];}	//End OF Test	$connectedto=$gcmd[1];	}	else	{		if($_SESSION['connectedto']==$gcmd[1])		{$_SESSION['cmdhis']='Unable To Bounce To/From Same LocationBouncing From:'.$_SESSION['connectedto'].' To:'.$gcmd[1].''.$_SESSION['cmdhis'];}		else		{		//START TEMP		$gconnect=mysql_query("SELECT * FROM $tbl_servers WHERE Server_IP='".$gcmd['1']."'");		$gconnect2=mysql_query("SELECT * FROM $tbl_computers WHERE IP='".$gcmd['1']."'");		if (mysql_num_rows($gconnect)>0)		{			$valid=1;		}		else if(mysql_num_rows($gconnect2)>0)		{			$valid=1;		}		if($valid==1)		{			$display=$_SESSION['connectedto'];			$_SESSION['cmdhis']='Connection To '.$gcmd[1].' Successful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];			$current=$_SESSION['connectedto'];			$new=$gcmd[1];			mysql_query("INSERT INTO $tbl_bounces (UID,`From`,`To`)VALUES(`{$_SESSION[iD]}`,`{$current}`,`{$new}`");			$_SESSION['connectedto']=$gcmd[1];			echo mysql_error();		}		else		{		echo $_SESSION['cmdhis']='Connection To '.$gcmd[1].' Unsuccessful'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];		}		//END TEMP		}	}}else if($gcmd[0]==" "){	$_SESSION['cmdhis']=''.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];}else{	$_SESSION['cmdhis']='Unknown Command'.$_SESSION["username"].'>'.$_GET['q'].''.$_SESSION['cmdhis'];}echo '<textarea rows="6" readonly=\"readonly\" width="100%" class="windowtext" name="cmdhis" scrolling="no">'.$_SESSION['cmdhis'].'</textarea>';if(isset($_SESSION['connectedto'])){echo'<br />Connected:'.$_SESSION['connectedto'];}else{echo'<br />No Connection';}?>

i always use this ' not ` or " you can try that see if it goesjust saw this
mysql_query("INSERT INTO $tbl_bounces (UID,`From`,`To`)VALUES(`{$_SESSION[iD]}`,`{$current}`,`{$new}`");

remove ` form around , From, Toso you colud try this

mysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES(`{$_SESSION[iD]}`,`{$current}`,`{$new}`");

Link to comment
Share on other sites

Cheers for the suggestions However it gives pretty much the same errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From, To)VALUES(`1`,`111.1.1.1`,`127.0.0.1`' at line 1hence the explaination before.

Link to comment
Share on other sites

Cheers for the suggestions However it gives pretty much the same errorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'From, To)VALUES(`1`,`111.1.1.1`,`127.0.0.1`' at line 1hence the explaination before.
did you try replacing the ` with ' ?like this
mysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES('{$_SESSION[iD]}', '{$current}', '{$new}' ");

just saw this try this

mysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES('{$_SESSION[iD]}', '{$current}', '{$new}') ");

heres how i normally do it.

mysql_query( "INSERT INTO table_name (something, something2)VALUES('{value}', '{value2}')");

Link to comment
Share on other sites

Yip, I've tried so the code becomesmysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES('{$_SESSION[iD]}','{$current}','{$new}'");
did you try it with the other bracket like mine?
Link to comment
Share on other sites

Like this?mysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES('{$_SESSION[iD]}', '{$current}', '{$new}')");same error
will that should work in less this $tbl_servers has no valueif not try something like my example
Link to comment
Share on other sites

Table servers defo has two values both 127.0.0.1 AND 111.1.1.1 (for testing) and theirs a script which shows this and only "connects" if they are valid from the table.
so you trying to put this into two tables in one mysql_query?im sure you have to do to 2 different querys to do that.are the names of the tables numbers or litters?other wise you lost me.
Link to comment
Share on other sites

code: mysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES('{$_SESSION[iD]}', '{$current}', '{$new}')");Code with static values: mysql_query("INSERT INTO bounces (UID, From, To)VALUES('1', '127.0.0.1', '111.1.1.1')");i wish to insert127.0.0.1 into where $current is and 111.1.1.1 where $new is Using variables (as the values changed based on the users choice) I've no idea why it doesn't work as i've done a range of php coding preiousely such as SweetMemoriesonline.co.uk so it's not like i'm a newbie.

Link to comment
Share on other sites

code: mysql_query("INSERT INTO $tbl_bounces (UID, From, To)VALUES('{$_SESSION[iD]}', '{$current}', '{$new}')");Code with static values: mysql_query("INSERT INTO bounces (UID, From, To)VALUES('1', '127.0.0.1', '111.1.1.1')");i wish to insert127.0.0.1 into where $current is and 111.1.1.1 where $new is Using variables (as the values changed based on the users choice) I've no idea why it doesn't work as i've done a range of php coding preiousely such as SweetMemoriesonline.co.uk so it's not like i'm a newbie.
i don't know ether never had this problem like this.only thing i could think of one of the values are wrong or invalided but im sure they are not.i run it though my debug for php & mysql and nothing comes up with an error.edit just saw this put ' around ID in $_SESSION[iD] not sure if that will get rid of the error or not but it'll help get the right data
Link to comment
Share on other sites

I've no idea, Must have been something wrong, Anyway after writing up a plan for the project (in this game game)It's going to take a different direction however most of the things will still be the same, but i'll cross this bridge if i come to it. If your interested you should be able to tell what type of game it is from the given script.Thank you for your help anyway

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...