php mysql connection

php mysql connection

Posted by: simondev
Posted on: 2003-12-08 23:41:00

Hi, I just signed up with DH and tyring to get my php scripts to write to my mysql database. Are you guys using pear - db.php? What about the DSN format?

I am getting an "access denied error".

The only response I've gotten from DH is to set up an odbc.ini file. Is this what you guys are using? Can you please send me a snippet of your connection code?

Very much appreciated,
Thanks,
simon

I can access my db no problem with the web interface same user, pass, and host name.

---------------------------test db script -------------

<?php
require_once 'DB.php';
$user = "xxxxx";
$pass = "xxxxx";
$host = "mysql.xxxx.com";
$db_name = "xxxxx";
$dsn = "mysql://$user:$pass@tcp+$host/$db_name";
$db = DB::connect($dsn);
if (DB::isError($db))
{
echo $db->getDebugInfo();
}
else
{
$email=$db->getOne("SELECT email from xxxxx_tbl where
userID=1");
echo"the email is $email";
}
?>


Re: php mysql connection

Posted by: Atropos7
Posted on: 2003-12-08 23:55:00

Have you tried the example script at http://pear.php.net/manual/en/package.database.db.intro-connect.php ? You don't need to specify the protocol in the DSN. I tried that example and it worked for me, all I had to do was cut & paste and edit the varaibles and remove the '...' and it worked, no odbc.ini file required. DH is running PHP 4.3.4 and the PEAR DB package that was released 9/14/2003.

cool Perl / MySQL / HTML CSS

Tags: simongottenappreciatedpearsnippetdsnhost nameweb interfaceini fileaccess deniedmysql databasemysql connectionphp scriptsphp mysql