0

I cant output the values of the row value to the html content any suggestions on how to do that? i tried using different methods so that i will print on the page but it's always blank is there any way to do it?

<?php 

//connect
$dbh=mysql_connect ("localhost", "xxxx_admin", "xxxx") 
   or die ('I cannot connect to the database.');
 mysql_select_db ("xxxx_Client"); 

$term = $_POST['term'];
echo $term;

$sql = mysql_query("select * from ClientTable where FName like '$term'");

if ($row['FName'] == $term){

$ID = $row['ID'];
$FName = $row['FName'];
$LName = $row['LName'];
$PHON = $row['PHON'];

}

else
echo "invalid input";

?>

<html>
<head>
<title></title>
</head>
<body>
asdadasdad<br>

<?php echo $FName; ?><br>a<br>
<?php echo $_POST["$LName"]; ?><br>a<br>

$FName <br>
$LName <br>
$ID <br>
$PHON <br>

sadasdasda
</bod>
</html>
3
  • 4
    Where are you setting $row? Commented Sep 6, 2012 at 15:49
  • you need some sort of $row = mysql_result($sql,0); call Incidentally, you should also use the mysqli_* functions as the mysql_* flavor are deprecated. Commented Sep 6, 2012 at 15:51
  • Take a look to these examples: php.net/manual/en/function.mysql-fetch-array.php Commented Sep 6, 2012 at 15:52

2 Answers 2

1

First, you are probably not getting any results from your query. Typically when using LIKE you use some form of wildcard in the query like this:

select * from ClientTable where FName like '%$term%'

Second, you are not actually working with the result set.

You need to use some sort of mysql_fetch_array or similar to get the values into $row.

And of course, you really should not be using the mysql_* functions anyway as they are being deprecated in favor of mysqli_* or PDO.

Finally, your need to learn how to prevent SQL injection. Your code is vulnerable now.

Sign up to request clarification or add additional context in comments.

Comments

0

Try adding error_reporting(E_ALL); near the beginning of your code. There is a good chance that a notice message will tell you what you're doing wrong.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.