Problem with script

From: Date: Tue, 02 Nov 2004 16:41:35 +0000
Subject: Problem with script
Groups: php.db 
Request: Send a blank email to php-db+get-37147@lists.php.net to get a copy of this message
Hi all, greetings from Phoenix, Arizona! I'm having a problem with a PHP script and the database it manages. I'm having his error message: Query failed: 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 't read card','1099413551')' at line 1 I don't know what is happening, usually the database works well but sometimes this strange error appears. I'm sending you the scripts in where I think the error could be. Any suggestion or comment will be very appreciated. Thanks Renato

<?php global $myDB,$tbl_prefix; if ($_GET['new'] == "no") { $query = "INSERT INTO ".$tbl_prefix."contact (contact_name, contact_company, contact_mco, contact_address, contact_telephone, contact_email, session_id) "; $query .= "VALUES ('".$_POST['contacto']."','".$_POST['empresa']."','".$_POST['mco']."','".$_POST['address']."','".$_POST['telefono']."','".$_POST['email']."','".$session_id."')"; $result = $myDB->query($query); $query2 = "SELECT contact_id FROM ".$tbl_prefix."contact WHERE contact_name = '".$_POST['contacto']."'"; $result2 = $myDB->query($query2); while ($row = mysql_fetch_assoc($result2)) { $contact_id = $row['contact_id']; } $query3 = "INSERT INTO ".$tbl_prefix."tmp (contact_id, order_brand, order_model, order_serialnumber, order_identification, order_description, order_date, session_id) "; $query3 .= "VALUES ('".$contact_id."','".$_POST['marca']."','".$_POST['modelo']."','".$_POST['nserie']."','".$_POST['identificacion']."','".$_POST['descripcion']."','".time()."','".$_GET['session_id']."')"; $result3 = $myDB->query($query3); $mylocation = "rma.php?page=form.php&new=yes"; print "<script language=\"Javascript\">\n"; print "window.location=\"".$mylocation."\";\n"; print "</script>\n"; } elseif ($_GET['new'] == "yes") { $query = "SELECT contact_id FROM ".$tbl_prefix."contact WHERE session_id = '".$_GET['session_id']."'"; $result = $myDB->query($query); while ($row = mysql_fetch_assoc($result)) { $contact_id = $row['contact_id']; } $query2 = "INSERT INTO ".$tbl_prefix."tmp (contact_id, order_brand, order_model, order_serialnumber, order_description, order_date, session_id) "; $query2 .= "VALUES ('".$contact_id."','".$_POST['marca']."','".$_POST['modelo']."','".$_POST['nserie']."','".$_POST['descripcion']."','".time()."','".$_GET['session_id']."')"; $result2 = $myDB->query($query2); $mylocation = "rma.php?page=form.php&new=yes"; print "<script language=\"Javascript\">\n"; print "window.location=\"".$mylocation."\";\n"; print "</script>\n"; } ?>
« previous php.db (#37147) next »