Jump to content

Parse error: syntax error, unexpected T_STRING in X:\xampp\htdocs\search.php on


priest_004

Recommended Posts

Hi folks,

 

I am a complete n00b at php and mysql. I am teaching myself from books and the WWW, but alas I am stuck...

 

the error I get is:

Parse error: syntax error, unexpected T_STRING in X:\xampp\htdocs\search.php on line 7

 

here is the code:

 

 


<?php
  
  mysql_connect ("localhost", "user", "password") or die (mysql_error());
  mysql_select_db ("it_homehelp_test") or die (mysql_error());
  
  $term = $_POST['term'];
  $sql = $mysql_query(select * from it_homehelp_test where ClientName1 like '%term%');   <<<------this is line 7
  while ($row = mysql_fetch_array($sql)){
  	echo 'Client Name:' .$row['ClientName1'];
echo 'Address:' .$row['Address1'];
echo 'Phone:' .$row['Tel1'];
}
?>

 

Any help you can offer would be great. I can also post the ".html" file that creates the search bar if it is needed.

 

Thanks

:)

Hi Dan, and Rifts,

 

I see it, I missed the " from the front and end... dough!!

 

thanks for pointing that out.

 

---------------------------------------

 

ok new problem... now it says...

 

Fatal error: Function name must be a string in X:\xampp\htdocs\search.php on line 7

 

I thought it was a string.

this is starting to hurt my head now... Same line..

 

???

what have i missed this time?

Ok folks,

 

I have sorted the FATAL ERROR now it is telling me..

 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in X:\xampp\htdocs\search.php on line 8

 

I think I might just have to go back to the drawing board for this one....

 

any clues on this?? code now reads..

 


<?php
  
  mysql_connect ("localhost", "user", "password") or die (mysql_error());
  mysql_select_db ("it_homehelp_test") or die (mysql_error());
  
  $term = $_POST['term'];
  $sql = mysql_query("select * from it_homehelp_test where ClientName1 like '%term%' "); 
  while ($row = mysql_fetch_array($sql)){
  	echo 'Client Name' .$row['ClientName1'];
echo 'Address' .$row['Address1'];
echo 'Phone' .$row['Tel1'];
}
?>

 

Turn error_reporting on, and print mysql_error.  mysql_query returns false when there is an error.  You are using "false" like a database result object, when clearly it isn't.

 

You're also using the word "term" instead of the variable $term, and you're not running $term through mysql_real_escape_string.

 

-Dan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.