Question
No results displayed when searching mysql
Hello!
When I search mysql database using the following code all I get is a white page. No results indicating there was any error or indication that the database or table couldn't be selected. What am I doing wrong? Any and all help will be greatly appriecated!
Thank you,
Amanda
<?php
DEFINE ('DB_USER', 'manda');
DEFINE ('DB_PASSWORD', '*****');
DEFINE ('DB_HOST', '**.***.**.***');
DEFINE ('DB_NAME', 'products');
$dbc = @6688122_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
@6688122_select_db (DB_NAME_ OR die ('Could not select the database; ' .
mysql_error() );
$search=$_POST["search"];
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM products WHERE item number LIKE '%$search%'");
//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$image=$r["title"];
$item number=$r["message"];
$title=$r["who"];
$description=$r["date"];
$price=$r["time"];
//display the row
echo "$image <br> $item number <br> $title <br> $description | $price <br>";
}
?>
---Of course I put n the correct info for the database connection, I just substitued it when I pasted the script. All the rest of the script is exactly what I used.
When I search mysql database using the following code all I get is a white page. No results indicating there was any error or indication that the database or table couldn't be selected. What am I doing wrong? Any and all help will be greatly appriecated!
Thank you,
Amanda
<?php
DEFINE ('DB_USER', 'manda');
DEFINE ('DB_PASSWORD', '*****');
DEFINE ('DB_HOST', '**.***.**.***');
DEFINE ('DB_NAME', 'products');
$dbc = @6688122_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );
@6688122_select_db (DB_NAME_ OR die ('Could not select the database; ' .
mysql_error() );
$search=$_POST["search"];
//get the mysql and store them in $result
//change whatevertable to the mysql table you're using
//change whatevercolumn to the column in the table you want to search
$result = mysql_query("SELECT * FROM products WHERE item number LIKE '%$search%'");
//grab all the content
while($r=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$image=$r["title"];
$item number=$r["message"];
$title=$r["who"];
$description=$r["date"];
$price=$r["time"];
//display the row
echo "$image <br> $item number <br> $title <br> $description | $price <br>";
}
?>
---Of course I put n the correct info for the database connection, I just substitued it when I pasted the script. All the rest of the script is exactly what I used.