I have tried connecting with php to my database but have been completely unsuccessful ;( I keep getting something like: "PHP Notice: Undefined variable: conn" I have tried each of the following:
$conn = new PDO("mysql:host=localhost;dbname=ar_data", 'login', 'pass');
$conn = mysqli('localhost', 'login', 'pass', 'dbname') or die("error" :.mysqli_connect_error());
$conn = mysqli_connect('localhost', 'login', 'pass', 'ar_data') or die("error" :.mysqli_connect_error());
After I tried that last one I got this on a var_dump($conn)
:
object(mysqli)#17 (18) { ["affected_rows"]=> int(0) ["client_info"]=> string(78)
"mysqlnd 5.0.8-dev - 20102224 - $Id: SOME_VALUE_I_AM_CENSORING $"
["client_version"]=> int(50008) ["connect_errno"]=> int(0) ["connect_error"]=> NULL
["errno"]=> int(0) ["error"]=> string(0) "" ["field_count"]=> int(0) ["host_info"]=>
string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=>
string(6) "5.5.25" ["server_version"]=> int(50525) ["stat"]=> string(140) "Uptime: 477847
Threads: 6 Questions: 202259 Slow queries: 1 Opens: 1454 Flush tables: 1 Open tables: 10
Queries per second avg: 0.423" ["sqlstate"]=> string(5) "00000"
["protocol_version"]=> int(10)
["thread_id"]=> int(1506) ["warning_count"]=> int(0) }
Also I have tried using users that do not have privileges to the ar_data database and it will give me an error for that as expected. If I do var_dump($conn)
right before a mysqli_prepare($conn, $sql)
then it will print NULL. How can I connect to the DB?
Notes: I have changed the name from conn to other vars incase it was getting changed but still same behavior. I also have Drupal 7 and Wordpress installed ( I imagine they are just using basic msql to connect)
UPDATE:
Entire file: https://dl.dropbox.com/u/6688861/phpconn.txt