Jump to content

What is wrong with this script?


jonoc33

Recommended Posts

$con = mysql_connect("localhost","*****","*****");
if (!$con)
  die('Could not connect: ' . mysql_error());
mysql_select_db("revolutiongamerz_net_-_clansolutions", $con);
$sql="INSERT INTO emails (accid, email, redirectto, activated)
VALUES ('" . $_POST["accid"] . "','" . $_POST["q1_E-mail"] . "','" . $_POST["q9_Redirectto"] . "','0')";
$rs = mysql_query($sql) or die ("Problem with the query, please contact webmaster@revolutiongamerz.net with this error: $sql <br>" . mysql_error);
echo "<center>Email added.";
echo "<center><a href=emails.php>Back</a>";

 

What is wrong with this script? Whenever I fill in a form on the previous page and hit submit it comes up with a Mysql error.

 

I typed in the E-mail box: Poo, and the Redirectto box: Poo@poo.com (the first field is filled in automatically from a hidden text box and the last one is just normal)

Link to comment
Share on other sites

dewey_witt the two pieces of code are functionally equivalent (except the code that the OP posted contains the 'Could not connect:' string which helps to identify where in the code the error occurred.) So that has nothing to do with the problem.

 

datafan, the two types of quotes are functionally equivalent in the concatenated post variable. So that has nothing to do with the problem.

 

jonoc33, you state you are getting a mysql error, what is it? Note: The syntax in the or die() statement for your INSERT query is incorrect. mysql_error should be mysql_error() This will help you find if there is a syntax error or an incorrectly named table or column in the query.

 

Echo your $sql variable to make sure what it actually contains. Just because you filled something in on a form, does not mean that it reached the php code. There could be a problem with the form code or a typo in a variable name.

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.