Jump to content

PHP Globals


cjosephson

Recommended Posts

First off, does the use of $GLOBALS['var1'] mean that register_globals needs to be set to on? I'm not sure if $GLOBALS is part of register_globals, or if it is an alternative to it.

 

The problem that sparks this question is this code:

<?php	

// Build SQL Query  
$query = "select * from allsw where name like \"%$GLOBALS[trimmed]%\"  
  order by name"; // EDIT HERE and specify your table and field names for the SQL query

$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

echo "$numrows";

?>

<?php echo($GLOBALS['numrows']);
?>

 

The first echo works perfectly, and spits out the correct number of results from the query. The second one, however, does not print anything out for some reason.

 

The $GLOBALS[trimmed] works perfectly and returns valid results, but it is not working for $GLOBALS[numrows].

 

Thank you for any help.

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.