|
-
Mar 28th, 2011, 06:05 PM
#1
Thread Starter
Addicted Member
Parse error: syntax error, unexpected T_INC,
Hi Folks,
I am having real trouble with my code. Could somebody have a look at it for me to see what I am doing wrong please? The code is pasted below.
Code:
<html>
<head>
<title>B&B cars</title>
</head>
<body>
<h1>Boys and Babes cars</h1>
<?php
//Some short variable declared
$searchtype=$_POST['searchtype'];
$searchterm=trim($_POST['searchterm']);
if (!$searchtype || !$searchterm) {
echo 'You did not enter any search term.';
exit;
}
if (!get_magic_quotes_gpc()) {
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
}
@ $db = new mysqli('localhost', 'root', '', 'cars');
if (mysqli_connect_error()) {
echo 'Error: Was not able to connect.';
exit;
}
$query = "select * from cars where ".$searchtype." like '%".$searchterm."%'";
$result = $db->query($query);
$num_results = $result->num_rows;
echo '<p>Number of cars found: ".$num_results."</p>';
for ($i=0; $i < $num_results; $++) {
$row = $result->fetch_assoc();
echo "<p><strong>". ($i+1).". Car: ";
echo htmlspecialchars(stripslashes($row['car']));
echo "</strong>"<br />Make: ";
echo stripslahes($row['make']);
echo "<br />Year: ";
echo stripslashes($row['year']);
echo "<br />Price: ";
echo stripslashes($row['price')];
echo "<p />";
}
$result->free();
$db->close();
?>
</body>
</html>
When I run the code above, I get the error message below,
Code:
Parse error: syntax error, unexpected T_INC, expecting T_VARIABLE or '$' in C:\xampp\htdocs\menre\products\cars\results.php on line 35.
I will welcome your help please.
Thanks,
Menre
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|