Jump to content

Recommended Posts

Hey guys, I have a variable that is within a while loop:

i.e:

while($row = mysql_fetch_array($result)
{
$var = $row[some_value];
}
if ...
{
   if
  {

...
  }
...
}

$var // i need to use the variable somewhere here but i still get it as empty ('')

 

I need that variable ($var) to work outside of the loop... is there a way to do that?

 

Any help would be great...

Link to comment
https://forums.phpfreaks.com/topic/137664-solved-variable-problem/
Share on other sites

Sorry I misread your question slightly before...

 

Can you post your actual code? Also how many rows are pulled from that database (roughly)? Just that $var is going to be overwritten every time your 'while' makes a loop and it could just be that the last record returned is simply empty!

 

A

Guys thanks for the responses but i solved it! the question was for carrying the value for later use but actually i didn't have to do anything, as it seems the value is being carried . I could not see it before cause i had an error in my sql query! Sorry for that.. and thanks again

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.