I am having trouble with a bit of code. It is supposed to be pulling information from a database. I copied and pasted the part connecting to the database from a part of the site that I know works, so that shouldn’t be the problem. I removed connection information from the code provided.
[php]<?php
$link = mysqli_connect("", “”, “”, “”);
if (!$link) {
die('Could not connect: ’ . mysqli_error());
}
$name=$_POST[‘name’];
$query=mysqli_query($link, “SELECT * FROM member_data
WHERE Name IS ‘$name’”);
WHILE ($rows=mysqli_fetch_array($query)) {
echo $rows[‘Name’] ."-". $rows[‘Job’];
echo “
”;
echo $rows[‘Details’];
}
mysqli_close();
?>[/php]
And what is the problem (apart from the gaping security hole)?
Hello,
First off, JimL behave yourself. Second, the last time I checked you want to use the equal sign to signify comparison.
[php]“SELECT * FROM member_data
WHERE Name IS ‘$name’”[/php]
Should be:
[php]“SELECT * FROM member_data
WHERE Name=’$name’”[/php]
Try that and see if it works.
OpzMaster
That did not solve the problem
No one knows what the problem is!
Please describe the problem you are having. Do you get any error messages? If not, try adding this to the beginning of the script and see if you now get any error messages.
[php]<?php
ini_set(‘error_reporting’, E_ALL);
ini_set(‘display_errors’, ‘1’);[/php]
I am receiving a Undefined index: name error. I made sure that the name column of my table was an index
$_POST[‘name’] is not set, so either you are not submitting the form or the form is not method=“POST” or the form does not have an input with name=“name”.
Thank you. This is now working. For some reason I thought on the form you needed to set the input name with id