PHP-MySQL coding

A

Anonymous

Guest
Can you solve this problem for the error?
Code:
<?

// search.php

require("globals.php");
require("common.php");
// Check if at least one search criteria is entered
if (!$cn && !$mail && !$locality && !$description && !$telephonenumber)
{
	DisplayErrMsg("Error: At least one search criteria should be present\n");
	exit();
}
// Generate the SQL command for doing a select from the Database
$searchStmt = "SELECT * from tableName where ";

if ($cn)
$searchStmt .= "name like '%$cn%' and ";
if ($mail)
$searchStmt .= "email like '%$mail%' and ";
if ($locality)
$searchStmt .= "city like '%$locality%' and ";
if ($description)
$searchStmt .= "description like '%$description%' and ";
if ($telephonenumber)
$searchStmt .= "telephone '$telephonenumber' and ";
$stmt= substr($searchStmt, 0, strlen($searchStmt)-4);
// Connect to the Database
if (!($link=mysql_pconnect($hostName, $userName, $password)))
{
	DisplayErrMsg(sprintf("error connecting to host %s, by user %s", $hostName, $userName));
	exit();
}
// Select the Database
if (!mysql_select_db($databaseName, $link))
{
	DisplayErrMsg(sprintf("Error in selecting %s database", $databaseName));
	DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link)));
	exit();
}
// Execute the Statement
if (!($result =mysql_query($stmt, $link)))
{
	DisplayErrMsg(sprintf("Error in executing %s stmt", $stmt));
	DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link)));
	exit();
}
// Display the results of the search
printf("<table border width="100%%" bgcolor="#dcdcdc" nosave>\n");
printf("<tr><td><b>Name</b></td><td><b>E-mail</b></td><td><b>City</b></td><td><b>Description</b></td><td><b>Telephone</b></td><td><b>Modify/Delete</b></td></tr>\n");
while (($row = mysql_fetch_object($result)))
{
	printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td><a href="modify.php?rowid=%s"><i>Modify</i></a>/<a href="delete.php?rowid=%s"><i>Delete</i></a></td></tr>\n", $row->name, $row->email, $row->city, $row->description, $row->telephone, $row->rowid, $row->rowid);
}
printf("</table>/n");
mysql_free_result($result);
ReturnToMain();
?>
Parse error: parse error, unexpected T_LNUMBER in D:\Program Files\Apache Group\Apache2\htdocs\edwinlamchouyin\test\AddressBook\search.php on line 48
 
printf("<table border width="100%%" bgcolor="#dcdcdc" nosave>\n");

it thinks you are opening/closing your string. Try escaping your quotes when you want to put a quote within a string.

printf("<table border width=\"100%\" bgcolor=\"#dcdcdc\" nosave>\n");
 
Back
Top