Jump to content

[SOLVED] Undefined Index issues and SQL syntax... you all probably see this a lot :-(


lcbrownmedia

Recommended Posts

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.  :facewall:

 

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! :-)

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.

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. :-)

Archived

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

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