Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code problem from Windows Server to Linux

Status
Not open for further replies.

WilliamMute

Programmer
Jan 4, 2006
117
Hi all,

I have the code below which worked fine when I was using it on my windows server. However I had a few problem with the windows server then I had to switch to a Linux based server. Once the switch was completed I started having problems with a number of my codes which worked fine previously. I have managed to solve quiet a few of them with the exeption of this one which I cant figure out and was hoping you could help.

QUERY
Code:
<?php
 if(!isset($HTTP_COOKIE_VARS['cart_id'])) {
     $cart_id = md5(uniqid(rand()));
     setcookie("cart_id", $cart_id, time() + 14400);
 } else {
     $cart_id = $HTTP_COOKIE_VARS['cart_id'];
 }

?>

<?php require_once('Connections/Connection.php');
 ?>

<?php
mysql_select_db($database_Connection) or die ("cannot connect to database ".mysql_error());
$sessionid = "$cart_id" ;

$sql = "
SELECT
        Sum(products.product_price * ylabelcart.quantity) AS total, ylabelcart.`session`
FROM
        products
        INNER JOIN
                    ylabelcart
                    ON
                    products.product_id = ylabelcart.product_id
GROUP BY
         ylabelcart.`session`
HAVING
        ylabelcart.`session`='$sessionid'";
		echo $sql;
$result=mysql_query($sql)
or die ("Query Error: " . mysql_error());
$row=mysql_fetch_assoc($result);
$amount = "" . number_format ( floatval($row['total']), 2, ".", ",");
?>

<?php
mysql_select_db($database_Connection, $Connection);



$sql  = "
SELECT products.product_name, products.product_price, products.image, products.product_id, ylabelcart.quantity, products.id
FROM ylabelcart
INNER JOIN
  products
  ON
    products.product_id = ylabelcart.product_id
WHERE
   ylabelcart.`session`='$sessionid'";
   echo $sql;
$result = mysql_query($sql) or die (mysql_error());
//$validation = 

?>

THE THE WHILE LOOP
Code:
while ($row=mysql_fetch_assoc($result)):
echo "<br/>" . $row['product_name'];
etc

The page is just blank even though I checked the DB and the records are there. I've also tried outputting the query which also seems fine.

Any help is appreciated. Thank You.
 
this is most likely to be a configuration thing. most probably related to long variables (such as $HTTP_COOKIE_VARS.

the use of variable names like this has been long deprecated in favour of the new superglobals $_COOKIE etc. you may find that your linux server has actually turned off their population through the register_long_arrays directive (if you are using php between 5.0.0 and 6.0.0. i believe in 6.0.0 the long arrays cannot be used at all (but am not certain of this).

you would do better to change references to $HTTP_*_VARS to their new equivalents of $_COOKIE/SERVER/POST/GET/SESSION etc.
 
Thanks for that Justin,

The problem is not even on the sessions it seems because when I echo out the query it seems fine. My guess is the while loop but I just dont know what it is. any suggestion with that?

Thanks once more
 
what error message are you getting (assuming that you have turned on display_errors and set error_reporting to E_ALL or E_STRICT)
 
Justin,

Am not that advance yet, sorry. How do I turn on display_errors and set error_reporting to E_ALL or E_STRICT?

I dont get errors on the page, it just dosnt display the records on the database. basically, its meant to grab all the records on the table where session_id = $cart_id etc. fetch the records and loop through echoing the contents out.

Thanks
 
edit php.ini and make sure that the directives error_reporting and display_errors are set as said.

make sure you edit the right php.ini. you can get the right one by looking at the info from running a script with just the following in it

Code:
<? phpinfo(); ?>
 
ok, i've just created a test.php with the code above this is what I found on the configuration detail.

error_reporting 2047 2047

display_errors On On
display_startup_errors Off Off

in addition, how will I go about editting this file? do I have to contact my Hosting company?

Many Thanks
 
I've just gone to my Hosting company's website to check if its possible to change my php.ini file and this is what they had on their support page

This file is not editable on the server and we are unable to change this for you for security reasons.

What other direction possible? thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top