I'm getting the error below, i've printed out the SQL query and its fine, it also works in the DB, SELECT sub_id,type FROM comments WHERE id='103' LIMIT 1, any ideas?
This is the code:
Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in C:\Apache\htdoc s\config\sql.ph p on line 798
Code:
function getCommentLink($id) { $link = ""; $type = ""; $sql = "SELECT sub_id,type FROM comments WHERE id='".$id."' LIMIT 1"; echo $sql; $sql = mysql_query($sql); while ($row = mysql_fetch_array($sql)) //Line 798 { $type = $row['type']; $sql = mysql_query("SELECT id,title FROM ".$row['type']." WHERE id='".$row['sub_id']."' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { if($type == "news") { $type = "article-news"; } else if($type == "reviews") { $type = "article-reviews"; } else if($type == "previews") { $type = "article-previews"; } $link = "../../../".$type."/".$row['id']."-".preg_replace('#[^a-zA-Z0-9]+#','-',$row['title']).".htm"; } } return $link; }
Comment