Jaloney Posted April 12, 2013 Share Posted April 12, 2013 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 More sharing options...
HartleySan Posted April 12, 2013 Share Posted April 12, 2013 Are you sure the DB name is 'acquia_drupal'? Also, are you sure the user name is 'root'? Link to comment Share on other sites More sharing options...
margaux Posted April 12, 2013 Share Posted April 12, 2013 Can you post precisely what error message you are receiving? $dbc=mysqli_connect("localhost","root",""); Try changing the above statement to include 4 parameters - host, dbusername, dbpassword, dbname Link to comment Share on other sites More sharing options...
Jaloney Posted April 13, 2013 Author Share Posted April 13, 2013 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 More sharing options...
Jaloney Posted April 13, 2013 Author Share Posted April 13, 2013 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 More sharing options...
HartleySan Posted April 13, 2013 Share Posted April 13, 2013 You said there were multiple errors. What errors were there aside from using the wrong user name? Link to comment Share on other sites More sharing options...
Recommended Posts