Passing a variable to list a single record from a list?

Web server Win 2008 Fasthosts shared server and PHP 5.4 mySQL database on Fasthosts server always worked up to the upgrade to Win 2008. Using Dreamweaver to construct site.
Connects to mySQL database fine and will list products on page all works fine. When you select a single product and use $_GET[‘hostID’] (hostID is the unique key field in the table)to select that record by passing it across no data gets selected just a blank page.

Something has changed in PHP 5.4 and I don’t have a clue what can anyone help please?

This is the connect code from the second page;

<?php require_once('Connections/hilbo.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_TestB = "0"; if (isset($_GET["hostID"])) { $colname_TestB = $_GET["hostID"]; } mysql_select_db($database_hilbo, $hilbo); $query_TestB = sprintf("SELECT * FROM hilbohosting WHERE hilbohosting.hostID = %s ", GetSQLValueString($colname_TestB, "int")); $TestB = mysql_query($query_TestB, $hilbo) or die(mysql_error()); $row_TestB = mysql_fetch_assoc($TestB); $totalRows_TestB = mysql_num_rows($TestB); ?>

The hostID comes from the page that calls this one, I don’t think the issue is in the code you posted, but perhaps the page that suppose to pass hostID.

You can view all the changes in php 5.4 here.

http://php.net/ChangeLog-5.php#5.4.0

Thanks for that I could not see anything odd in the first page but what do I know after a frustrating day it seems nothing this is the code in question from the firt page;

<?php require_once('Connections/hilbo.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_TestA = 10; $pageNum_TestA = 0; if (isset($_GET['pageNum_TestA'])) { $pageNum_TestA = $_GET['pageNum_TestA']; } $startRow_TestA = $pageNum_TestA * $maxRows_TestA; mysql_select_db($database_hilbo, $hilbo); $query_TestA = "SELECT * FROM hilbohosting "; $query_limit_TestA = sprintf("%s LIMIT %d, %d", $query_TestA, $startRow_TestA, $maxRows_TestA); $TestA = mysql_query($query_limit_TestA, $hilbo) or die(mysql_error()); $row_TestA = mysql_fetch_assoc($TestA); if (isset($_GET['totalRows_TestA'])) { $totalRows_TestA = $_GET['totalRows_TestA']; } else { $all_TestA = mysql_query($query_TestA); $totalRows_TestA = mysql_num_rows($all_TestA); } $totalPages_TestA = ceil($totalRows_TestA/$maxRows_TestA)-1;$maxRows_TestA = 10; $pageNum_TestA = 0; if (isset($_GET['pageNum_TestA'])) { $pageNum_TestA = $_GET['pageNum_TestA']; } $startRow_TestA = $pageNum_TestA * $maxRows_TestA; mysql_select_db($database_hilbo, $hilbo); $query_TestA = "SELECT * FROM hilbohosting "; $query_limit_TestA = sprintf("%s LIMIT %d, %d", $query_TestA, $startRow_TestA, $maxRows_TestA); $TestA = mysql_query($query_limit_TestA, $hilbo) or die(mysql_error()); $row_TestA = mysql_fetch_assoc($TestA); if (isset($_GET['totalRows_TestA'])) { $totalRows_TestA = $_GET['totalRows_TestA']; } else { $all_TestA = mysql_query($query_TestA); $totalRows_TestA = mysql_num_rows($all_TestA); } $totalPages_TestA = ceil($totalRows_TestA/$maxRows_TestA)-1; ?> <?php do { ?>

Hosting Services we offer;
<?php echo $row_TestA['type']; ?>

Server
<?php echo $row_TestA['server']; ?>

Server Details
<?php echo $row_TestA['servdetails']; ?>

Email Offered
<?php echo $row_TestA['email']; ?>

<?php echo $row_TestA['emaildetail']; ?>
<?php echo $row_TestA['connection']; ?>

Price £<?php echo $row_TestA['price']; ?>

Ask Us?


<?php mysql_free_result($TestA); ?> <?php } while ($row_TestA = mysql_fetch_assoc($TestA)); ?>

That’s not the page either there is no Form Element with the ID of “hostID”.

OK this works on an old site
This is the link that selects the record to be edited and it works fine. I tested the pages and updated records today so it is working OK, it was done in Dreamweaver 8 and coded the pages just fine, this site has been moved onto the Windows 2008 server with the PHP up to 5.4

Edit

This does not work now and returns a syntax error message

ASK US

What puzzles me is why not work on both can you see what I have missed?

More than a cup of coffee if you can solve this as a reward.
Tony

Sorry for the late reply…

Did you fix this yet?

What syntax error are you getting?

Sponsor our Newsletter | Privacy Policy | Terms of Service