jonoc33 Posted November 29, 2007 Share Posted November 29, 2007 $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 More sharing options...
dewey_witt Posted November 29, 2007 Share Posted November 29, 2007 <? $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()); Link to comment https://forums.phpfreaks.com/topic/79374-what-is-wrong-with-this-script/#findComment-401841 Share on other sites More sharing options...
datafan Posted November 29, 2007 Share Posted November 29, 2007 I think it's the double quotes in the arrays '".$_POST["q1_E-mail"]."' should be '".$_POST['q1_E-mail']."' Link to comment https://forums.phpfreaks.com/topic/79374-what-is-wrong-with-this-script/#findComment-401842 Share on other sites More sharing options...
dewey_witt Posted November 29, 2007 Share Posted November 29, 2007 Good eyeballs man lol Link to comment https://forums.phpfreaks.com/topic/79374-what-is-wrong-with-this-script/#findComment-401844 Share on other sites More sharing options...
PFMaBiSmAd Posted November 29, 2007 Share Posted November 29, 2007 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 https://forums.phpfreaks.com/topic/79374-what-is-wrong-with-this-script/#findComment-401903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.