I can connect to MySQL server but not the DB. So on my webpage it shows "Connected to MySQL" but then underneath that I get "Could not select examples which tells me it didn't connect to the database". Could anyone help?
<?php
$username = "user_admin";
$password = "Password";
$hostname = "localhost:3306";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
?>
**<?php
//select a database to work with
$selected = mysql_select_db ("my_dbname", $dbhandle)
or die("Could not select examples");
?>**
<?php
$sql = "SELECT * FROM `company` WHERE \'companyname\' like \'%a%\' LIMIT 0, 30 ";
while($row = mysqli_fetch_array($sql))
{
echo $row['companyname'];
echo "<br>";
}
mysql_close($con);
?>
\'companyname\'my_dbnamedoesn't exist. Are you 10000% it does?mysql_is deprecated. But use the command line to check permissions. i.e. dev.mysql.com/doc/refman/5.6/en/mysql.html