Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I can't seem to get past this error.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /windsor.php on line 47

if ($insertdb == NULL)
  mysql_query("INSERT INTO `asd` (`id`, `1`, `2`,`3`, `4`, `5`, `pubdate`) VALUES (296, maddeal', 'Windsor', 'ON', '', '', '') ON DUPLICATE KEY UPDATE `1`=VALUES(`1`),`2`=VALUES(`2`),`3`=VALUES(`3`),`4`=VALUES(`4`),`5`=VALUES(`5`)") or die(mysql_error());
 else
//Check and see if value has changed...

$checksql = mysql_query("SELECT `1` FROM deal WHERE `id`= 296") or die(mysql_error());
while($row = mysql_fetch_array($checksql))
  {
  $checksqlver = $row['deal'];
  }

$checksqlver = mysql_real_escape_string($checksqlver);
//$checksqlver = stripslashes($checksqlver);
echo "$checksqlver<br>";

if ($checksqlver == $insertdb)
  exit();
 else
  echo "No Match<br>";

//percent
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

Did you connect to the database using mysql_connect?

That would cause the error you are describing.

share|improve this answer
    
Yes, I have that specified at the top, just didn't post. Other scripts work, just this one is giving me grief... –  mrlayance Jan 28 '11 at 1:05
    
You also have an else statement there where you don't have any code until the $checksql = ... try removing that else. –  Alec Gorge Jan 28 '11 at 1:08
    
That was it... kinda –  mrlayance Jan 28 '11 at 1:21
    
replaced else //Check and see if value has changed... with else echo "Moving On"; Not that best fix, but it works. –  mrlayance Jan 28 '11 at 1:22
    
Excellent. PHP could really stand to make their errors a little more specific as to what the problem actually is... In your case it is because you passed a null value to mysql_fetch_array because $checksql was declared in a different scope. –  Alec Gorge Jan 28 '11 at 1:23
add comment

In your select query should 1 have apostrophes around it?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.