Jump to content

[SOLVED] PHP MYSQL short code NOT WORKING WTF!! help me please ty


Recommended Posts

Guys this code is doing NOTHING. wth is going on :'(!?!?!? help me please! :shrug:

 

<?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!!

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.

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.

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.