Jump to content

!mysql_query not working


The14thGOD

Recommended Posts

I can't seem to find the mistake in this code:

 

<?php
$com_query = "SELECT * FROM comments WHERE picID='$_GET[id]' AND status='enabled' ";
					$com_result = mysql_query($com_query);
					if(!mysql_query($com_query)) {
							echo "<p class=\"nocomments\">There are no comments yet.</p>";
					}?>

 

It's not echoing hi, it appears to not be getting inside that if statement.

 

That reads if no mysql_query (meaning query returned nothing) then do this right? or have i been gone from php that long...hah

 

Thanks in advance

 

Justin

Link to comment
Share on other sites

Try this:

 

<?php
$com_query = "SELECT * FROM `comments` WHERE `picID`='".mysql_real_escape_string($_GET['id'])."' AND `status`='enabled'";
$com_result = mysql_query($com_query)
  or die("Query error: ".mysql_error());
if(mysql_num_rows($com_result)) {
  while($row = mysql_fetch_array($com_result)){
    //Print Comments Here
  }
}else{
  echo '<p class="nocomments">There are no comments yet.</p>';
}
?>

Link to comment
Share on other sites

Ah, alright. I swear I've used that same code before though... ha. Oh well.

 

Conker87, I tried that already, I noticed that wasn't right and changed it but for the reason Boom.dk said it didn't work.

 

Thanks again,

 

I'd hit the topic solved button but I can never find the damn thing. I found it once...haha

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.