Im thinking this isn't an exact duplicate of the other question because i "am not trying to mix api's". I do not want to anyway. My db host provider told me to change the code because i could not get this first code to connect till i changed it to what they say. Perhaps since I changed that, I have to change the rest of the code to match or because i left the code the same "i am mixing api's"? Im so confused.
This is the code i use on my local host and my entire php file (with html) works fine.
<?php
$dbHost = 'localhost';
$dbUsername = 'root';
$dbPassword = '';
$dbName = 'example';
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
if ($db->connect_error) {
die("Unable to connect database: " . $db->connect_error);
}
?>
When on my server i had to change it to this in order for it to connect properly.
<?php
$dbHost = 'user.ipowermysql.com';
$dbUsername = '';
$dbPassword = '';
$dbName = '';
$db = mysql_connect($dbHost, $dbUsername, $dbPassword);
mysql_select_db($dbName, $db);
if ($db->connect_error) {
die("Unable to connect database: " . $db->connect_error);
}
?>
I got that part figured out. I asked power and they said i can't use mysql i and have to use mysql. I don't understand why but it works.
Now when I try to call to get info onto my webpage using this code below, I get an error. Everything on the webpage above the php call shows up but everything on the webpage after the php code is somehow gone and of course the code doesn't work. Here is the code I'm using on the page to call. This works fine on localhost and shows the full webpage and gets the info I'm calling but not on server. Im completely new to php and was happy to get it finally working on my localhost. Now I'm loosing it trying to figure it out on the server
<?php
$query = $db->query("SELECT * FROM slideshow ORDER by ID ASC");
if($query->num_rows > 0){
while($row = $query->fetch_assoc()){
?>
<img src="<?php echo $row["image"]; ?>"/>
<?php } } ?>
Here is the error i get: PHP Fatal error: Call to a member function query() on a non-object.