Jump to content
Larry Ullman's Book Forums

Chap 9 Connecting To Mysql And Select Statement


Recommended Posts

Hello

My instructor routinely gives assignments where the code doesn't work and we have to fend for ourselves to figure out what the issue is. My assignment is to enter this code and connect to Acquia Drupal database.

 

i keep getting an error referring to link 1 where the database connect statement is given.

The database doesn't have a password. I did enter the code in Phpmy admin before I tried to upload it to the Acqui-Drupal desktop to find the error in line one. 

 

This is the code. He doesn't use the same syntax as the book which makes learning harder.

Any idea what is wrong with the database connect statement? I did try adding my user name and password in the connect mysqli_connect statement but it did not help.

 

<?PHP

//book page 268
$dbc=mysqli_connect("localhost","root","");

mysqli_select_db($dbc,"acquia_drupal");

$query="select name from role";
$r=mysqli_query($dbc,$query);

while($row=mysqli_fetch_array($r))
{
echo $row['name']."<br />";
}

mysqli_close($dbc);
?>

 

 

Link to comment
Share on other sites

Hello,

I changed root to drupal user

as my config file for sql has

this: [client]

port=3306

user=drupaluser

 

[mysql]

 

[mysqladmin]

user=root

port=3306

 

 

So  now I get this error:

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Users\Owner\Sites\acquia-drupal\CO241\my_script.php on line 11  

Perplexed.

 

Jaloney

Link to comment
Share on other sites

Hello all,

I resolved the problem, FINALLY.. there were multiple errors. For starters the user name was not root.....The suggestions got me searching for the right parameters, and finally resolved my problem. YEAH.

Thank you,

Jaloney

Link to comment
Share on other sites

 Share

×
×
  • Create New...