Jump to content

Recommended Posts

code

<?php
//storecodefound.php v1.0
//purpose is to store the http refer and the code associated with the site to a db to be collected and verified by submitcode.php
$code = $_GET['code'];
$site = $_SERVER['HTTP_HOST'];


//check to see if the code already present
$connect = mysql_connect("localhost","root","") or die (mysql_error());
$check = mysql_query("SELECT code FROM hunter.codes WHERE code='$code'") or die (mysql_error());
$row = mysql_num_rows($check);
echo "result of \$row is ".$row;
echo "<br />";
if ($row = 0) {
//insert into db cause it's not there
mysql_query("INSERT INTO hunter.codes (id, code, site)
VALUES ('','$code','$site')") or die (mysql_error());
}
else {
//echo it's already here
echo "Code already found on server!";
}





?>

my question is the result of $row is infact 0 and the if statement says if $row is 0 to insert into db and instead it's given me the code is already found?

Link to comment
https://forums.phpfreaks.com/topic/224337-quick-question/
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.