MySQL and PHP works locally, not on GoDaddy

Nintendoman

New Member
I'm using GoDaddy's Shared Linux hosting and some PHP I wrote just won't work with my DB on the server.EDIT:I fixed the problem. I accidentally deleted the "database" connection variable from a config file. Wow. That was silly of me.EDIT: By not work, I mean that I can't read the DB. I've messed around enough to know that the DB is running and that when I modify the password variable I get 'Access Denied'. Furthermore, on localhost, the password is different and it works. EDIT 2:I am now working with the sample script from GoDaddy. It now shows up a blank page. At least there are no errors... I changed the password to be alphanumeric. I am not using 'localhost'.EDIT 3: With the correct password and server info I get the following error using mysql_error(). I am not using a leading http:// in the db url.Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Edit 4:Here is my connection code.Please note that \[code\]nl()\[/code\] and \[code\]report()\[/code\] are predefined functions that echo newlines and diagnostic messages respectively. The connection variables are in an external file, included above. I've checked - the includes are working just fine.\[code\]//////////////////////////////// Connect to the database /////////////////////////////////////////////////////////////////////////report - Attemting to establish connection ...report(4);//////Step 1) Set connection in variable////$conn = mysql_connect($server, $user, $pass);////// Step 2) Verify the connection////if(!$conn){ //report - failed, see next line... report(5); //report - FATAL ERROR: Check database name, username and password. report(9); }else{ //report - done! report(7);}//report - Selecting database ...report(6);////// Step 3) Select the database////$db_select = mysql_select_db($database);////// Step 4) Verify successful selection////if(!$db_select){ //report - failed, see next line... report(5); //report - FATAL ERROR: Could not select database. report(8); }else{ //report - done! report(7);}//report - Running query ...report(10);////// Step 5) Create the original the query////$selector = " * ";$target = "`properties`";$condition = "1";$sql = "SELECT " . $selector . " FROM " . $target . " WHERE " . $condition;////// Step 6) Check for a $_GET[] parameter////if($_GET['listing'] && !is_null($_GET['listing'])){ //if a listing number was supplied $listingNum = htmlentities($_GET['listing']); //safety first - clean it from code injections $pattern = '/\b[0-9]{1,6}\b/'; //define a range of valid, sercheable listings if(preg_match($pattern,$listingNum) == 1){ //if the listing id is a valid one $sql .= " AND `listing_id` =" .$listingNum . ""; //search for it in the database }elseif($exp == 0){ //if the listing number is out of range if($listingNum != "all"){ //check if the "all" keyword was ommitted - if it was not supplied. //report - failure ... see below report(5); //report - Invalid listing ID report(12); // // Invalid Listing ID... // } }}else if(!$_GET['listing']){ //report - failure ... see below report(5); //report - Invalid listing ID report(12); // //No listing ID //}if(!$sql){ //report - failed, see next line... report(5); //report - FATAL ERROR: Could not run query. report(11); // // For some reason the query doesn't exist here. I really do wonder why. //}else{ //report - done! report(7); nl();}$result = mysql_query($sql); //perform the actual queryif(!$result){ echo("There's been some sort of error with the search lookup. Here are the details: \n" . mysql_error());}mysql_close($conn); //close the connection to the SQL server\[/code\]
 
Back
Top