lcbrownmedia Posted July 28, 2009 Share Posted July 28, 2009 Hi everyone, I'm relatively new (ok, really new) to PHP script and mySQL use. My company and I are trying to keep track of our media uses (we are a production house) and thought a simple online form that we could access could keep record. The code and form works great on my host provider, however I am trying to put it on a WAMP server on our intranet. On the WAMP however, it doesn't work. I keep getting this error: Notice: Undefined index: used in C:\wamp\www\script.php on line 10 Error: 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 'inout, purpose, employee) VALUES ('origproductions','John Doe','xdhd','yes',''' at line 1 Here's the PHP Script code the form points to: <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mediadata", $con); $sql="INSERT INTO stock (department, customerid, mediatype, new, used, quantity, inout, purpose, employee) VALUES ('$_POST[department]','$_POST[customerid]','$_POST[mediatype]','$_POST[new]','$_POST[used]','$_POST[quantity]','$_POST[inout]','$_POST[purpose]','$_POST[employee]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Media Recorded"; mysql_close($con) ?> Does anyone have any ideas? It works great on my host provider, but not on my WAMP. (I even downgraded everything on the WAMP to match my host provider versions). Thanks! :-) Link to comment https://forums.phpfreaks.com/topic/167737-solved-undefined-index-issues-and-sql-syntax-you-all-probably-see-this-a-lot/ Share on other sites More sharing options...
waynew Posted July 28, 2009 Share Posted July 28, 2009 Basically, it's saying that no POST value called 'used' exists. Double check the form that is posting to this code to make sure that you actually have a form input (or whatever) with the name "used". This is not a problem with the WAMP server. It would have been doing the same on the other server, it's that your other server had error reporting turned off. Link to comment https://forums.phpfreaks.com/topic/167737-solved-undefined-index-issues-and-sql-syntax-you-all-probably-see-this-a-lot/#findComment-884693 Share on other sites More sharing options...
patrickmvi Posted July 28, 2009 Share Posted July 28, 2009 You may want to do a print_r($_POST) to try and help you troubleshoot the issue. Link to comment https://forums.phpfreaks.com/topic/167737-solved-undefined-index-issues-and-sql-syntax-you-all-probably-see-this-a-lot/#findComment-884820 Share on other sites More sharing options...
lcbrownmedia Posted July 28, 2009 Author Share Posted July 28, 2009 Thanks everyone! I was able to narrow it down using the print command and found out that it was the "inout" post that was causing the issue. Don't really know why, but when I removed it from the form everything worked (I think Dreamweaver screwed it up, even though id="inout"). Anyways, rewrote the entry and it's working fine now. :-) Link to comment https://forums.phpfreaks.com/topic/167737-solved-undefined-index-issues-and-sql-syntax-you-all-probably-see-this-a-lot/#findComment-885032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.