Jump to content

funny coding error


thedevilinu

Recommended Posts

Link to comment
Share on other sites

@PFMaBiSmAd -

I really expect the loop to run just once as their is only a single id associated with any email.

You are however right in saying that loop is running more than once. I can't fathom why it is running twice.

so changing the code to

------------------------------

$result = mysql_query("SELECT * FROM indiatutors_profiles WHERE id='$id' ") or die(mysql_error());

  while($row=mysql_fetch_array($result)){

      echo $email =$row;

  }

------------------

gives me error

----------------

email@gmail.com

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in website_path/profiles.php on line 7

----------

which confirms that loop runs twice. Bug was using another $result statement in the code due to which it was running again. Thanks for sorting this out for me.

Thanks again

 

@rifts - it works either way mate..my way is just time saving

@dragon - echo in or out of the loop .. either way it shouldn't give an error

 

 

 

Link to comment
Share on other sites

$query = "SELECT * FROM indiatutors_profiles WHERE id=$id"; // Presumes that $id is a numeric value.
$result = mysql_query($query) or die("<br>Query string: $query<br>Produced error: " . mysql_error());
$row=mysql_fetch_assoc($result);
echo $row['email']; // And yes, the array index should be enclosed in quotes. Just because it works without them, doesn't mean it's right.

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.