physaux Posted October 14, 2009 Share Posted October 14, 2009 Guys this code is doing NOTHING. wth is going on :'(!?!?!? help me please! <?php function requestcaptcha($email, $ip){//NOT WORKING WITH DATABASE..? global $connection; $result = mysql_query("SELECT * FROM captchabyemail WHERE email = '".$email."'", $connection); if (!$result) die("Database query failed: " . mysql_error()); $setyet=false; while ($row = mysql_fetch_array($result)) { if($row["email"] == $email){ $setyet=true; $temp= $row["num"]+1; $result = mysql_query("DELETE FROM captchabyemail WHERE email = '".$email."'"); if (!$result) die("Database query failed: " . mysql_error()); $result = mysql_query("INSERT INTO captchabyemail VALUES('".$email."', ".$temp.")"); if (!$result) die("Database query failed: " . mysql_error()); } } if(setyet==false){ $result = mysql_query("INSERT INTO captchabyip VALUES('".$email."', 1)"); if (!$result) die("Database query failed: " . mysql_error()); } ?> I ofcourse run the function as echo requestcaptcha($email, $ip), and i get a captcha created and all but nothing is added to database!! Quote Link to comment https://forums.phpfreaks.com/topic/177612-solved-php-mysql-short-code-not-working-wtf-help-me-please-ty/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 14, 2009 Share Posted October 14, 2009 The following line is missing a $ in front of setyet - if(setyet==false){ Please develop php code and debug php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you find simple mistakes. You will save a ton of time. Stop and start your web server to get any change made to php.ini and confirm that the settings are actually changed using a phpinfo() statement. Quote Link to comment https://forums.phpfreaks.com/topic/177612-solved-php-mysql-short-code-not-working-wtf-help-me-please-ty/#findComment-936472 Share on other sites More sharing options...
physaux Posted October 14, 2009 Author Share Posted October 14, 2009 Thanks alot, i thought i had it on but i set it on now 100%. I also corrected your suggestion, AND i had "INT" datatype instead of "STRING" in my table... which was making the comparisons of "email" and "email" always false because one was string and one was int, ahh... but peace finally. THANK YOU!! The following line is missing a $ in front of setyet - if(setyet==false){ Please develop php code and debug php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini to get php to help you find simple mistakes. You will save a ton of time. Stop and start your web server to get any change made to php.ini and confirm that the settings are actually changed using a phpinfo() statement. Quote Link to comment https://forums.phpfreaks.com/topic/177612-solved-php-mysql-short-code-not-working-wtf-help-me-please-ty/#findComment-936533 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.