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

:)

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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'];
}
?>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.