Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Silly function in PHP

Status
Not open for further replies.

zWaR

Programmer
Dec 1, 2004
20
SI
Somebody explain me this please, cause i'm loosing my mind:

Code:
function ureditev_tabele($rezultat) {
  echo "<table>";
  while ($i < mysql_num_fields($rezultat)) {
    $ime=mysql_fetch_field($rezultat,$i);
    if (isset($HTTP_POST_VARS[$ime->name])) {
       printf("<tr><td>%s</td></tr>",$ime->name);
    }
    $i++;
    echo "</table>";
}

ureditev_tabele($rezultat);

Code:
  echo "<table>";
  while ($i < mysql_num_fields($rezultat)) {
    $ime=mysql_fetch_field($rezultat,$i);
    if (isset($HTTP_POST_VARS[$ime->name])) {
       printf("<tr><td>%s</td></tr>",$ime->name);
    }
    $i++;
    echo "</table>";

Code No.1 doesn't give me no output, but code No. 2 does. Why???????
 
If code is as is, then you're missing some curly braces. If that is all your code, it shouldn't really work. How would this work?
Code:
function ureditev_tabele($rezultat) {
  echo "<table>";
  while ($i < mysql_num_fields($rezultat)) {
    $ime=mysql_fetch_field($rezultat,$i);
    if (isset($HTTP_POST_VARS[$ime->name])) {
       printf("<tr><td>%s</td></tr>",$ime->name);
    }
    $i++;
    echo "</table>";
  }
}

ureditev_tabele($rezultat);
If that is not it, what is actually happening in your code?

PS. Are you from Slovenia?
 
Nope, the missing brace fell off by copy/paste. And it isn't the whole code no. I've allready deleted the file and am trying to achieve the goal an other way.

Yes i am from SLO, why are you asking?
 
I am from Slovenia too. I recognized the language and it was funny to me, because I usually don't see it on this forum. Which PHP version are you using? Might be a scope problem. $_POST[] is a superglobal array and if you have a chance to use it I suggest you do.
 
yeah, i know $_POST is commonly used these days, but it's for a bit older php ver on the servers of the company i'm working at. Hehe, i could imagine, you were suprised. Usualy i change the names to english, for better understanding, but today i just weren't in the right mood. The function made me headacke. But it's over now :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top