june_c21 Posted December 16, 2010 Share Posted December 16, 2010 hi , can someone tell me what 's wrong with this query ? INSERT INTO out( name , section , wo , printer_name , toner_code , quantity , remarks , technician , trainee ) VALUES ('$name','$section','$wo','$printer_name','$toner_code','$quantity', '$remarks','$technician','$trainee') thanks Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/ Share on other sites More sharing options...
joel24 Posted December 16, 2010 Share Posted December 16, 2010 ## edit ## sorry, had a bit of a mind slip. disregard my previous post. as for the error in your query, is it returning an error? what is happening?? and what is your full code for that... i.e. @mysql_query("INSERT into ......"); Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148002 Share on other sites More sharing options...
denno020 Posted December 16, 2010 Share Posted December 16, 2010 As joel is saying above, you need to provide more information, show the php code where this query is run. Also, make sure you have a value going into every column of your database table. I counted 9 entries from this query, is there exactly 9 columns in your database table? Denno Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148007 Share on other sites More sharing options...
harristweed Posted December 16, 2010 Share Posted December 16, 2010 It appears that you have a field called 'name'. This is a reserved word in mysql. Change this field name and the query will work. Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148012 Share on other sites More sharing options...
june_c21 Posted December 16, 2010 Author Share Posted December 16, 2010 here is my code <?php include './includes/header.php'; $id = $_GET ['id']; $names = $_POST ['names']; $section = $_POST ['section']; $wo = $_POST ['wo']; $printer_name = $_POST ['printer_name']; $toner_code = $_POST ['toner_code']; $quantity = $_POST ['quantity']; $remarks = $_POST ['remarks']; $technician = $_POST ['technician']; $trainee = $_POST ['trainee']; $query= "INSERT INTO out( names , section , wo , printer_name , toner_code , quantity , remarks , technician , trainee ) VALUES ('$names','$section','$wo','$printer_name','$toner_code','$quantity', '$remarks','$technician','$trainee') "; $result = mysql_query($query,$dblink); $query= "UPDATE master SET qty= qty - $quantity WHERE id= $id"; $result = mysql_query($query,$dblink ); echo "Inventory Successfully Saved. "; ?> the error i get is #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 'out( names , section , wo , printer_name , toner_code , quantity , remarks , tec' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148133 Share on other sites More sharing options...
denno020 Posted December 16, 2010 Share Posted December 16, 2010 INSERT INTO out( names , section , wo , printer_name , toner_code , quantity , remarks , technician , trainee ) VALUES ('$names','$section','$wo','$printer_name','$toner_code','$quantity', '$remarks','$technician','$trainee') I don't think you need to have the information in the brackets after INSERT INTO out. Take out that and see what happens. Denno Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148138 Share on other sites More sharing options...
denno020 Posted December 16, 2010 Share Posted December 16, 2010 My answer above is wrong, sorry about that. However I did find out what your problem is. You can't have out as a table name. It is a reserved word, so you will have to change it. Reference: http://www.htmlite.com/mysql002a.php Denno Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148145 Share on other sites More sharing options...
Pikachu2000 Posted December 16, 2010 Share Posted December 16, 2010 OR - enclose `out` in backticks (not single quotes) as shown any time it appears in a query string. Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148162 Share on other sites More sharing options...
june_c21 Posted December 17, 2010 Author Share Posted December 17, 2010 thanks Quote Link to comment https://forums.phpfreaks.com/topic/221843-query/#findComment-1148485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.