djfox Posted February 25, 2007 Share Posted February 25, 2007 I get the following errors: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/secrett1/public_html/trances.php on line 23 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 '' at line 1 & instead of loading any part of the file, the whole thing is blank after that. Here`s the coding, can anyone figure out what is wrong with it & know how to fix it: $lev=$_SESSION['level2']; $res = mysql_query("SELECT id, name, gallNum, URL, rating, numRates, description, views, cat, addDate, feature, literature FROM image WHERE id=$id"); if ($rows = mysql_fetch_row($res)) { return $rows; } else { print (mysql_error()); } if($submit){ $s = $sub." by ".$name; $b= emote($bod); mysql_query("INSERT INTO comment (imageID,subject,content,date,sender) VALUES ( '$id', '$s', '$b', NOW(),$send)")or die ( mysql_error()); mysql_query("INSERT INTO messagedata (recBoxID, sendBoxID, content, subject, isNew, date) VALUES ($rows[2], '7', 'You have a new comment on one of your trances that you have submitted. Click here to read the comment. This is automated message please do not reply.', 'New Comment Received', 1, NOW() )"); } if($policy && ($lev>6)){ mysql_query("UPDATE userdata SET violations=SUM(violations,1) WHERE login='$name'"); } $res = mysql_query("SELECT login FROM userdata WHERE id='$rows[2]'"); if ($by = mysql_fetch_row($res)) { return $by; } else { print (mysql_error()); } $res = mysql_query("SELECT icon FROM userdata WHERE id='$rows[2]'"); if ($icon = mysql_fetch_row($res)) { return $icon; } else { print (mysql_error()); } $res = mysql_query("SELECT name, id FROM imagecats WHERE id=$rows[8]"); if ($catName = mysql_fetch_row($res)) { return $catName; } else { print (mysql_error()); } $res = mysql_query("SELECT COUNT(*) FROM comment WHERE imageID='$id'"); if ($numCom = mysql_fetch_row($res)) { return $numCom; } else { print (mysql_error()); } $res = mysql_query("SELECT COUNT(*) FROM userdata WHERE imageFav='%$id%'"); if ($numFavs = mysql_fetch_row($res)) { return $numFavs; } else { print (mysql_error()); } //Update unique pageview counter if( !$_SESSION["sess_$id"] ){ $_SESSION["sess_$id"] = "visited"; $v = $rows[7] + 1; mysql_query("UPDATE image SET views=$v WHERE id='$id'"); } Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 25, 2007 Share Posted February 25, 2007 Your query is generating an error. Add "or die ( mysql_error());" to all of your queries to see what the error is. Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 Your query is generating an error. Add "or die ( mysql_error());" to all of your queries to see what the error is. It just gives the same error messages. Quote Link to comment Share on other sites More sharing options...
btherl Posted February 25, 2007 Share Posted February 25, 2007 Your queries should look like this: $res = mysql_query(...) or die(mysql_error()); Right now you're checking for the error in the wrong place, although it works by luck. As for finding the error, try rewriting your queries again like this, so you can inspect the query you are executing: $sql = "SELECT ..."; $res = mysql_query($sql) or die("Error in $sql\n" . mysql_error()); Then you can see the query which failed. If you can't find the syntax error in the query, post the query here for us to look at. Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 Your queries should look like this: $res = mysql_query(...) or die(mysql_error()); Right now you're checking for the error in the wrong place, although it works by luck. As for finding the error, try rewriting your queries again like this, so you can inspect the query you are executing: $sql = "SELECT ..."; $res = mysql_query($sql) or die("Error in $sql\n" . mysql_error()); Then you can see the query which failed. If you can't find the syntax error in the query, post the query here for us to look at. Now it says: Error in SELECT id, name, gallNum, URL, rating, numRates, description, views, cat, addDate, feature, literature FROM image WHERE id= 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 '' at line 1 Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 Change your line from: $res = mysql_query("SELECT id, name, gallNum, URL, rating, numRates, description, views, cat, addDate, feature, literature FROM image WHERE id=$id"); To: $res = mysql_query("SELECT id, name, gallNum, URL, rating, numRates, description, views, cat, addDate, feature, literature FROM image WHERE id='$id'); Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 Change your line from: $res = mysql_query("SELECT id, name, gallNum, URL, rating, numRates, description, views, cat, addDate, feature, literature FROM image WHERE id=$id"); To: $res = mysql_query("SELECT id, name, gallNum, URL, rating, numRates, description, views, cat, addDate, feature, literature FROM image WHERE id='$id'); Now the page is completely white with just this error message: Parse error: syntax error, unexpected T_STRING in /home/secrett1/public_html/trances.php on line 30 Line 30 is: $s = $sub." by ".$name; Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 hmmm, try this real quick instead. $s = $sub; $s.=" by "; $s=$name; Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 hmmm, try this real quick instead. $s = $sub; $s.=" by "; $s=$name; Oh lorddie, once on thing is changed, another one comes up: Parse error: syntax error, unexpected T_STRING in /home/secrett1/public_html/trances.php on line 31 line 31 is $s.=" by "; Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 You need those spaces in there? Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 You need those spaces in there? Well if it doesn`t have the second space, it`ll print "byusername" rather than "by username". Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 Does this work? $s = $sub." "."by"." ".$name; Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 Does this work? $s = $sub." "."by"." ".$name; Page still comes back blank, now with this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/secrett1/public_html/trances.php on line 30 Line 30 would be the code you just gave me. Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 Sorry i am just throwing stuff out here before I goto bed. I have no idea why your original didn't work. Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 Yeah it`s really weird & is nearly making me think about sticking with the other host that has really bad service. Quote Link to comment Share on other sites More sharing options...
djfox Posted February 25, 2007 Author Share Posted February 25, 2007 Still need help with this. Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 25, 2007 Share Posted February 25, 2007 From your post on Reply#4 it is apparent that $id has no value. Where are you setting it? Quote Link to comment Share on other sites More sharing options...
itsmeArry Posted March 1, 2007 Share Posted March 1, 2007 this is not correct $s = $sub." "."by"." ".$name; use this... $s = $sub." by ".$name; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.