Jump to content

Invalid resource... Why?


don4of4

Recommended Posts

Hi everyone,

 

Im building a page that takes a list of values from check boxes and writes entries to a mysql database.  I have 1 issue left.  Any help is greatly appreciated.

 

I get this error:

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in ... on line 42

 

When a Die() is added on line 41:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `row` = '1'' at line 1

 

This is line 41:

$query= mysql_query("SELECT $select WHERE `row` = '$prow'") or die(mysql_error());

 

This is line 42:

$pquery = mysql_result($query,0);

 

This is the surrounding code:

$prow=1;
$pcol=1;
$ip=$_SERVER['REMOTE_ADDR'];
$numadded =0;
while ($prow != 12) 
		{
		If ($_POST[$prow.'_r'.$pcol] != null)
				{
				$select= "r".$pcol."_data_name";

				$query= mysql_query("SELECT $select WHERE `row` = '$prow'");
				$pquery = mysql_result($query,0);

				mysql_query("INSERT INTO `merit` (`name`,`merit`, `ip`) 
				VALUES('$formatname','$pquery','$ip')"); 
				$numadded = $numadded +1;
				}
		if ($pcol == 4) {$pcol=1; $prow = $prow + 1;} else {$pcol = $pcol + 1;}
		}

Link to comment
https://forums.phpfreaks.com/topic/205215-invalid-resource-why/
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.