Jump to content

quick question


desjardins2010

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.