Code:
Parse error: syntax error, unexpected T_VARIABLE in /home/crazy4/public_html/m4e5.php on line 24
PHP Code:
<?php
$getmake = $_GET['make'];
$address = "localhost";
$username = "xxxx";
$password = "xxxx";
$db = "xxxx";
$table = "xxxx";
$dbConnection = mysql_connect($address, $username, $password);
function getCheapestHandset($make, $handset, $dbConnection) {
$statement = "SELECT handsetid, handset, gift, tariff, xnet, offpeak, texts FROM $table WHERE make='{$make}' AND handset='{$handset}' ORDER BY total LIMIT 1";
$resultSet = mysql_query($statement, $dbConnection);
if (!$resultSet) { /* Handle error */ }
$result = mysql_fetch_assoc($resultSet);
mysql_free_result($resultSet);
return $result;
}
function getHandsets($make, $dbConnection) {
$result = array();
$statement = "SELECT DISTINCT handset FROM $table WHERE make='{$getmake}'"
$resultSet = mysql_query($statement, $dbConnection);
if (!$resultSet) { /* Handle error */ }
while (($row = mysql_fetch_row($resultSet))) $result[] = $row[0];
mysql_free_result($resultSet);
return $result;
}
$make = mysql_real_escape_string($_GET['make'], $dbConnection);
foreach (getHandsets($make, $dbConnection) as $handset) {
$cheapestHandset = getCheapestHandset($make, mysql_real_escape_string($handset),
$dbConnection);
echo("{$cheapestHandset['handset']}")
}
Bookmarks