This forum is no longer active. Please post your questions to our new community site

Recent Posts by silliemunkie

Subscribe to Recent Posts by silliemunkie 3 post(s) found

07 Jul, 2009 09:19 PM
Avatar silliemunkie 3 post(s)

Topic: MAMPStack / error when accessing mysql from PHP

i get the following error when trying to access my database:

Warning: mysqli::mysqli(): (HY000/2002): Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2) in /- on line 3 Warning: mysqli::query(): Couldn’t fetch mysqli in /- on line 4 Warning: main(): Couldn’t fetch mysqli in /- on line 4

the calling code is:

<?php

$mysql = new mysqli(‘localhost’, ‘root’, ‘password’, ‘db’) or die(‘you\’re dead’);
$result = $mysql→query(“SELECT * FROM mytable”) or die($mysql→error);

if($result) {

while($row = $result→fetch_object()) {
$name = $row→name;
# note that this isn’t ideal – to echo out text before the doctype. This is just for example. In a real-world app, we’d echo this info out within the container div.
echo $name . “
”;
}
}
?>

I’m sure I am missing a configuration step somewhere, but can’t seem to get the right combination.

thank you,
Jason

 
06 Jul, 2009 07:09 PM
Avatar silliemunkie 3 post(s)

Topic: MAMPStack / access to mysql

Hello,
that is exactly what I needed! thank you for your help.

Jason

 
04 Jul, 2009 03:00 AM
Avatar silliemunkie 3 post(s)

Topic: MAMPStack / access to mysql

I have been looking, and can’t seem to find out how to connect to mysql from the commmand line, and from within code. any guidance would be greatly appreciated.

Jason