Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:16:01+00:00 2026-05-25T20:16:01+00:00

I wonder whether someone may be able to help me please. I’m trying to

  • 0

I wonder whether someone may be able to help me please.

I’m trying to use the script below to return data from a mySQL into a HTML form.

 <?php
require("phpfile.php");  

// Opens a connection to a MySQL server  

$connection=mysql_connect ("host", $username, $password);  
if (!$connection) { die('Not connected : ' . mysql_error());}  

// Set the active MySQL database  

$db_selected = mysql_select_db($database, $connection);  
if (!$db_selected) {  
die ('Can\'t use db : ' . mysql_error());  
}  


$email = $_POST['email']
$sql = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");

while($row = mysql_fetch_array($sql))
  {
  echo $row['forename']; 
  echo $row['surname'];
  echo "<br />";
  }
?> 

The field which is used to match the input data to that held in my database is the email address. Basically if the keyed in email address matches a record in the database, it returns the first and surname.

However when I run it I receive the following error:

Parse error: syntax error, unexpected T_VARIABLE in
/homepages/2/d333603417/htdocs/development/search.php on line 18

Where Line 18 is:

$sql = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");

I’ve taken the source code from a tutorial I found on the Internet and I’ve been back to the source and rechecked my field names etc and I can’t find out what the problem is.

Could someone perhaps take a look at this and let me know where I’m going wrong please?

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:16:01+00:00Added an answer on May 25, 2026 at 8:16 pm
    $email = $_POST['email']
    $sql = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");
    

    change to:

    $email = $_POST['email'];
    $sql = mysql_query("SELECT * FROM userdetails WHERE emailaddress like '%$email%'");
    

    you forgot the ; after declaring your $email variable.

    Also, the clue here is unexpected T_VARIABLE.

    Basically, unexpected means that the script was doing something and unexpectedly encountered something it shouldn’t have during the process. In this case it unexpectedly encountered a variable ( T_VARIABLE ) when it was “expecting” a semi colon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. From some demos
I wonder whether someone may be able to help me please. I'm trying to
I wonder whether someone may be able to help please. I'm using the script
I wonder whether someone may be able to help me please. I'm trying to
I wonder whether someone may be able to help me please. Using the script
I wonder whether someone may be able to help me please. I'm trying to
I wonder whether someone may be able to help me please. I currently use
I wonder whether someone may be able to help please. I'm trying to put
I wonder whether someone may be able to help me please. I'm using Aurigma
I wonder whether someone may be able to help me please. I've put together

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.