Jump to content

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 [email protected] 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: [email protected] (the first field is filled in automatically from a hidden text box and the last one is just normal)

Link to comment
https://forums.phpfreaks.com/topic/79374-what-is-wrong-with-this-script/
Share on other sites

<?
$con = mysql_connect("localhost","*****","*****") or die(mysql_error());

?>

 

Try that instead of the long check you have hoing on there.

$con = mysql_connect("localhost","*****","*****");

if (!$con)

  die('Could not connect: ' . mysql_error());

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.

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.