daveh33 Posted November 13, 2007 Share Posted November 13, 2007 if ($free) { $query = mysql_query("SELECT * FROM vids WHERE number='$free'") or die("cant get free vid info"); $row = mysql_fetch_array($query) or die("error with this row"); $videourlfree = $row['videourl']; $imgurlfree = $row['imgurl']; } The code stops and displays the message: error with this row -any ideas??? Link to comment https://forums.phpfreaks.com/topic/77168-solved-error-with-simple-mysql-query/ Share on other sites More sharing options...
toplay Posted November 13, 2007 Share Posted November 13, 2007 You should not put a die on the fetch since there might not be any data returned as is that is not really considered an error. The number column might be a reserved word in MySQL so you should enclose it in back tick marks. Also, display any MySQL errors to help yourself solve the problem. Example: <?php if ($free) { $free = mysql_real_escape_string($free); $strSql = "SELECT * FROM `vids` WHERE `number` = '$free'"; $objResult = mysql_query($strSql); if ($objResult) { $arrRow = mysql_fetch_assoc($objResult); if ($arrRow) { $videourlfree = $arrRow['videourl']; $imgurlfree = $arrRow['imgurl']; } else { echo 'No data matched your query'; } } else { die('SQL: ' . $strSql . ' Error: ' . mysql_error()); } } ?> Link to comment https://forums.phpfreaks.com/topic/77168-solved-error-with-simple-mysql-query/#findComment-390738 Share on other sites More sharing options...
toplay Posted November 13, 2007 Share Posted November 13, 2007 I've closed this topic because you already had another post. Do not do this again. http://www.phpfreaks.com/forums/index.php/topic,167517.0.html Link to comment https://forums.phpfreaks.com/topic/77168-solved-error-with-simple-mysql-query/#findComment-390745 Share on other sites More sharing options...
Recommended Posts