Member Avatar for Ralphael

I am relatively new to php and i am having this error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1" and i cant figure out what is wrong with my code. My code is written below

<?
  	$name = $_POST['yell'];
	echo '<table bordercolor="#000000" border="solid">';
		echo	"<tr><td>FirstName</td><tr>";
		echo	"<tr><td>$name</td></tr>";
		echo	"</table>";
		mysql_connect("localhost:8080", "root", "") or die(mysql_error());
		mysql_select_db("test") or die(mysql_error());
	/*ff*/
	$queue = "SELECT * FROM employer WHERE FName = $name";
		$result = mysql_query($queue) or die(mysql_error());	
		$query =  mysql_fetch_array($result);
		$fname = $query['FName'];
		$lname = $query['LName'];
		$address = $query['address'];
		$tele = $query['telephone'];
		
		echo '<table bordercolor="#000ff0" border="solid">';
		echo"<tr><td>FName</td><td>LName</td><td>address</td><td>Telephone</td><tr>";
		echo"<tr>";
		echo"$fname";
		echo"<td></td>";
		echo"<td>";
		echo"$lname";
		echo"</td>";
		echo"<td>";
		echo"$address";
		echo"</td>";
		echo"<td>";
		echo"$tele";
		echo"</td>";
		echo"</tr>";
		echo"</table>";
		
  ?>

Please i will love to hear suggestions

Member Avatar for Ralphael

please can some one help me here i am really desperate

assuming FName is a string, your query needs to reflect that.
change this:

$queue = "SELECT * FROM employer WHERE FName = $name";

to this:

// wrap $name in tick marks '$name'
$queue = "SELECT * FROM employer WHERE FName = '$name'";
Member Avatar for Ralphael

thanks i tried it and it solved that issue but now it is giving another error "Notice: Undefined index: address in C:\wamp\www\tests\action.php on line 15" and "Notice: Undefined index: telephone in C:\wamp\www\tests\action.php on line 16" when i try the page

Member Avatar for Ralphael

it also did not print out the whole record instead it only brought out the last name

Member Avatar for Ralphael

works now thanks ddymacek

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.