0

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

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Ralphael
0

please can some one help me here i am really desperate

1

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'";
0

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

0

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

0

works now thanks ddymacek

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.