Jump to content

[SOLVED] Same PHP code run on 2 different Lamp servers (I get different results


nipsilanti

Recommended Posts

Please Help,

I have been running mysql and php5 on a remote host for the past year without any problems.  I recently built my own server in-house with the following specs.

Ubuntu 8.10 64bit, mysql5.0.67, Apache2.2.9, php5.2.6-2 and phpmyadmin2.11.8.1deb1.  My php code that works on the remote server no longer performs the proper query on my server.  Goal of my php code is to query test data by (site),(pressure) and (clampType).  (Site) and (clampType) work fine. I used a $_Get to capture the sort criteria but it seems to ignore pressure altogether.  It is outputting to the url fine but the query ignores it.  Any thoughts would be greatly appreciated.  I believe the problem is configuration related and not code related but any expert thoughts in the matter would be greatly appreciated. Attached is the code.  I already tried using the php.ini file from the remote site.  That didn't work.

 

$connection = mysql_connect($host, $user, $pass, $dbb);

$link = mysql_select_db($dbb,$connection) or die(mysql_error());

switch ($link)



{

case TRUE:

echo "Connected ThankYou...";

break;

case FALSE:

echo "Not Connected";

}









if(isset($_GET['db'])){

$db = $_GET['db'];

}

if(isset($_GET['clampID'])){

$clampID =  $_GET['clampID'];

}

if(isset($_GET['clampType'])){

$clampType = $_GET['clampType'];

}

if(isset($_GET['limit'])){

$limit = $_GET['limit'];

}

if(isset($_GET['Pressure'])){

$pressure = $_GET['Pressure'];

}




//New Code to include clampType in query ***





else if(!isset($clampID)&& isset($pressure)&& isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE Pressure = '$pressure' AND clampType = '$clampType' ORDER BY $db.Date, $db.clampID";

}





else if(isset($clampID)&& !isset($pressure)&& isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE clampID = '$clampID' AND clampType = '$clampType' ORDER BY $db.Date, $db.clampID";

}





else if(isset($clampID)&& isset($pressure)&& !isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE clampID = '$clampID' AND Pressure = '$pressure' ORDER BY $db.Date, $db.clampID";

}





else if(!isset($clampID)&& !isset($pressure)&& isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE clampType = '$clampType' ORDER BY $db.Date, $db.clampID";

}





else if(isset($clampID)&& !isset($pressure)&& !isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE clampID = '$clampID' ORDER BY $db.Date, $db.clampID";

}



else if(!isset($clampID)&& isset($pressure)&& !isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE Pressure = '$pressure' ORDER BY $db.Date, $db.clampID";

}



else if(isset($clampID)&& isset($pressure)&& isset($clampType)){

        $queryString = "SELECT *,

                     WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db WHERE clampID = '$clampID' AND Pressure = '$pressure' AND clampType = '$clampType' ORDER BY $db.Date, $db.clampID";

}







else{

$queryString = "SELECT*,

             WtUB/TotalWt*100 AS pUB,

             WtUF/TotalWt*100 AS pUF,

             WtLB/TotalWt*100 AS pLB,

             WtLF/TotalWt*100 AS pLF

         FROM $db  ORDER BY $db.Date, $db.clampID";

}







$result = mysql_query($queryString, $connection);

$num=mysql_numrows($result);

echo $num;

mysql_close();

Link to comment
Share on other sites

What exactly is the symptom that leads you to believe that the pressure is being ignored? What result are you getting vs what do you expect?

 

Have you echoed $queryString to see what it contains?

 

Add the following two lines immediately after your first opening <?php tag -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Link to comment
Share on other sites

I have an html form with drop down list for each selection criteria.

The user can pick the site, the pressure, and the clamp type.

The user then submits the data and it goes to my  php file.

My $_get  function  puts it in the url:  fpull_color2_ctype_wtf1_09.php?db=whr_ga_lithia_springs_r432&pressure=H&clampType=A

I can try all the combinations and it produces the same result whether I select a pressure or not.  Historically the program would not

run my query unless a pressure was selected.  That is why I believe the problem is isolated to the pressure variable.

 

Thanks,

Link to comment
Share on other sites

Hi Everyone,

I have attached both php.ini files.

I tried replacing the php.ini.original = the bad one with php.ini1 and the result was the same.

 

I'll continue to play with it until the problem is solved and post my findings.

Thanks everyone for their help and I'll let you know how it turns out.

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Thanks all for the echo option to see what was passing.

I echo'd from my HTML page and figured out the $GET method was no passing my 3rd variable.

I switched to the $POST method and everything worked fine.

I'm up and running and all is good.

I just don't understand why the $GET method is flushed on later versions of php5. Is this is a config issue? 

 

 

Thanks for the advice and all the help... I hope to return the favor in the future.

 

 

Quote: PHP and MYSQL truly shows computing Horse Power... Skip the GUI BS....

Nipsilanti  (Was a great Town)RIPB3

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.