don4of4 Posted June 18, 2010 Share Posted June 18, 2010 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 More sharing options...
Mchl Posted June 18, 2010 Share Posted June 18, 2010 The syntax for SELECT is: SELECT columns FROM table WHERE conditions Link to comment https://forums.phpfreaks.com/topic/205215-invalid-resource-why/#findComment-1074178 Share on other sites More sharing options...
don4of4 Posted June 18, 2010 Author Share Posted June 18, 2010 :wtf: :wtf: :wtf: :wtf: I hate when I do things like that... Anyway, thanks! That was the problem. Link to comment https://forums.phpfreaks.com/topic/205215-invalid-resource-why/#findComment-1074188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.