Jump to content

Recommended Posts

Hi,

 

I've come across a situation today thats confusing the hell out of me

 

if(isset($GLOBALS["_GET"])){

while(list($key, $val) = each($GLOBALS["_GET"])) {

//echo "test ".$key." ".$val." ";

$key = stripslashes($key);

$val = stripslashes($val);

$key = urlencode($key);

$val = urlencode($val);

$getString .= "$key=$val&";

}

}

 

if(!is_array($inQuery)){ // if it's a MySQL query

//get db records

$conn = db_connect();

$outputResult = $conn->query($inQuery); //the result object result

$outputCount = $outputResult->num_rows; //the result object resultCount

$outputResult->free_result();

$conn->close();

 

} else { // if it's an array

$outputCount = count($inQuery); // Count the number of elements in the array

}

 

echo "1 ".$getString;

 

//dont do anything else if there arent enough records to warrant prev/next

if ($outputCount <= $limit){

$this->navDump = "";

$this->outQuery = $inQuery;

return;

}

 

echo "2 ".$getString;

 

The variable $getString, is created by the first part of the script.

An example of the output for this is "sMethod=music&sText=thunder&x=9&y=6" and this works fine.

 

The problem has appeared today when sText was 60s making the string "sMethod=music&sText=60s&x=9&y=6"

 

Echo 1 displays it fine however after the "return;" command it wipes the variable so echo 2 will not print it.

 

I've tried a few different variations and it seems when sText has a number in it return; wipes the variable.

 

Any ideas would be greatly appreciated as its got me completely stumped.

 

Cheers

 

 

Link to comment
https://forums.phpfreaks.com/topic/52951-v-v-confused/
Share on other sites

Hi,

 

Its not that the echo is not calling as the IF statement is not entered and it prints out the number 2, and the rest of the script after that is fine, it just clears the $getString variable.  I know its the "return;" causing the problem as it works fine if I comment it out.

 

 

Link to comment
https://forums.phpfreaks.com/topic/52951-v-v-confused/#findComment-261535
Share on other sites

This is only part of the script.  The function is designed to take a query or array along with a limit and offset and output it only displaying the required results.  It also outputs a navigation bar (i.e. prev 1234 next).  That IF statement is only called if there isn't enough records to warrant a nav bar so it ends the function.

 

On this occasion there is enough records for a nav bar so that IF statement isn't called.

 

The part that is confusing me is that this script has worked fine for months until recently when someone entered 60s as the sText and because $getString cleared, the navigation doesnt work properly as these are the GET's added to the end of each link.

Link to comment
https://forums.phpfreaks.com/topic/52951-v-v-confused/#findComment-261538
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.