I have the function pt_replace:

function pt_register()
  $num_args = func_num_args();
   $vars = array();

   if ($num_args >= 2) {
       $method = strtoupper(func_get_arg(0));

       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');

       $varname = "HTTP_{$method}_VARS";
      global ${$varname};

       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);

           if (isset(${$varname}[$parameter])) {
               global $$parameter;
               $$parameter = ${$varname}[$parameter];


   } else {
       die('You must specify at least two arguments');


Which is used for the following reasons:


I know everything works up until this point and the variables are being passed as otherwise I would receive an error message if any of the values were null.

I have a MySQL database with the tables "boxes" and "sent". "touser" in the "sent" table has exactly the same value as "thecode" in boxes.

$hount = mysql_num_rows(mysql_query("SELECT theid FROM sent WHERE theid='$themsg' LIMIT 1"));

$check1 = mysql_query("SELECT touser FROM sent WHERE theid='$themsg'");
$check2 = mysql_query("SELECT thenum FROM boxes WHERE thecode='$check1'");

if ($hount == "1")


if ($check2 = $thenumbar) {

$result = mysql_query("SELECT * FROM sent WHERE theid='$themsg' LIMIT 1") 

or die(mysql_error());  

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

$fromip = $row['fromip'];

$themsh = $row['themsg'];

$theday = $row['thedate'];

echo "<div align='center'><b>Message:</b><br>$themsh<br><br> <b>When:</b><br> $theday</div>";


else {
die("Wrong number!");


} else {

echo "<div align='center'><font size='5' color='red'>Non-existant</font></div>";

If I echo $check1 and $check2 before the die("Wrong number!"); function, $check1 has a value of "Resource id #5" and $check2 is null. My level of PHP and MySQL is still pretty basic, so it could be a ridiculous problem.

Thanks for the help, Cuchara2.

Recommended Answers

All 3 Replies

I did not study the code thoroughly, but noticed this assignment

if ($check2 = $thenumbar)

which should probably be a comparison instead

if ($check2 == $thenumbar)

I looked through again and fixed some silly mistakes like that (there were two in total) and now $thenumbar is being received correctly. The code still doesn't work however :(

$check2 is a handle to the mysql query, AKA resource. You have to retrieve the rows from this resource with mysql_fetch_array or mysql_fetch_object or similar functions before you can use the column values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.