Jump to content

MYSQL Error code:


timothyltaylor

Recommended Posts

Can anyone help me figure out why nothing is going into the database from this end?
I would really appreciate it! (specifically in the "mysql_query("INSERT INTO" statement)
  Thank you...

Here's my code:
[code]<?
$classdateandlocation=$_POST['classdateandlocation'];
$instructors=$_POST['instructors'];
$comments=$_POST['comments'];
$name=$_POST['name'];
$email=$_POST['email'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$phone=$_POST['phone'];

$Q1=$_POST['Q1'];
$Q2=$_POST['Q2'];
$Q3=$_POST['Q3'];
$Q4=$_POST['Q4'];
$Q5=$_POST['Q5'];
$Q6=$_POST['Q6'];
$Q7=$_POST['Q7'];
$Q8=$_POST['Q8'];
$Q9=$_POST['Q9'];

}
if(trim($_POST['classdateandlocation']) == "") {
  die("*No <b>Class Date and Location</b> was entered, please click back button and fill in required fields");
}
if(trim($_POST['instructors']) == "") {
  die("*No <b>Instructors</b> were entered, please click back button and fill in required fields");
}
if(trim($_POST['comments']) == "") {
  die("*No <b>Comments</b> were entered, please click back button and fill in required fields");
}
if(trim($_POST['name']) == "") {
  die("*No <b>Name<b/> was entered, please click back button and fill in required fields");
}
if(trim($_POST['address']) == "") {
  die("*No <b>Address</b> was entered, please click back button and fill in required fields");
}
if(trim($_POST['city']) == "") {
  die("*No <b>City<b/> was entered, please click back button and fill in required fields");
}
if(trim($_POST['state']) == "") {
  die("*No <b>State</b> was entered, please click back button and fill in required fields");
}
if(trim($_POST['zip']) == "") {
  die("*No <b>Zip</b> was entered, please click back button and fill in required fields");
}
if(trim($_POST['phone']) == "") {
  die("*No <b>Phone</b> was entered, please click back button and fill in required fields");
}
if(trim($_POST['Q1']) == "") {
  die("<b>*Question 1<b/> wasn't filled out, please click back button and fill in required fields");
}

mysql_connect("mysite.com", "xxxxxxx", "xxxxxxxxxxx") or die(mysql_error());
mysql_select_db("xxxxxxx_com_xxxxx") or die(mysql_error());
mysql_query("INSERT INTO `data` VALUES ( '$classdateandlocation', '$instructors', '$comments','$name', '$email', '$address', '$city', '$state', '$zip', '$phone')");
if(trim($_POST['classdateandlocation']) == "") {
  die("*No <b>Class Date and Location</b> was entered, please click back button and fill in required fields");

Print "Your information has been successfully added to the database.";
echo "<p>Here is what you entered:<p>";
echo "<p><b>Class Date and Location:</b> $classdateandlocation<p>";
echo "<p><b>Instructors:</b> $instructors<p>";
echo "<p><b>Comments:</b> $comments<p>";
echo "<p><b>Name:</b> $name<p>";
echo "<p><b>Email:</b> $email<p>";
echo "<p><b>Address:</b> $address<p>";
echo "<p><b>City:</b> $city<p>";
echo "<p><b>State:</b> $state<p>";
echo "<p><b>Zip:</b> $zip<p>";
echo "<p><b>Phone:</b> $phone<p>";

echo "<p><b>This learning Experience was:</b> $Q1<p>";
echo "<p><b>Were the stated learning objectives met?:</b> $Q2<p>";
echo "<p><b>If applicable, were prerequisites appropriate?:</b> $Q3<p>";
echo "<p><b>Were program materials both accurate and effective?:</b> $Q4<p>";
echo "<p><b>Did program materials contribute to the achievement of the learning Objectives?:</b> $Q5<p>";
echo "<p><b>Was the time allotted to the learning experience appropriate?:</b> $Q6<p>";
echo "<p><b>Were the facilities and/or the technological equipment appropriate?:</b> $Q7<p>";
echo "<p><b>Were the handouts and advanced preparation materials satisfactory?:</b> $Q8<p>";
echo "<p><b>Was the classroom facilitators knowledge and experience satisfactory for the course material?:</b> $Q9<p>";
   


  mail("myname@mysite.com", "EPSA CAP2 Evaluation Results from $name", $body, $email, $headers );
?>[/code]

       Lee
Link to comment
Share on other sites

Well save the query as a variable and add an [code]or die(mysql_error() ."<br>$query");[/code] to the end of your mysql_query statement. It helps to troubleshoot if you can see what went wrong.

Having the wrong column count is the most common problem for that type of query.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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