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
https://forums.phpfreaks.com/topic/61588-php-globals/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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