flash gordon Posted November 15, 2007 Share Posted November 15, 2007 Can anybody see what is wrong with this script? The error message is: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/r/i/t/ritahunt/html/httpdocs/test/candleData.php on line 12 Could not connect and the script I'm using is: /* * DATABASE INFO */ $username = "Phil01"; $password = "******"; $db = "Phil01"; $table = "candledata"; // Conect to the database. mysql_connect("localhost", $username, $password) or die ("Could not connect to database"); mysql_select_db($database) or die ("Could not select database"); It works fine on my own host and locally. However, when I upload it to the GoDaddy server it doesn't work. I don't know enough php to understand what the problem is. help? Cheers Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 15, 2007 Share Posted November 15, 2007 For you server, you may have to put something other than "localhost". If I remember right, when I used GoDaddy I had to put the actual server. If you browse through the help files you will find what your supposed to use. Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 15, 2007 Share Posted November 15, 2007 mysql_select_db($database) or die ("Could not select database"); To mysql_select_db($db) or die ("Could not select database"); Quote Link to comment Share on other sites More sharing options...
flash gordon Posted November 16, 2007 Author Share Posted November 16, 2007 Thanks Daukan, but that's just a mistake on my part. I double checked it, and I still get that error. @pocobueno1388, yea that was my though too so I called godaddy but the told me they offer now support for there hosting packages. I couldn't find what I was supposed to use.... Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 16, 2007 Share Posted November 16, 2007 Does GD have a Knowledge Base or other type of web support? You might need a port number too, if their MySQL server isn't at default 3306. PhREEEk Quote Link to comment Share on other sites More sharing options...
flash gordon Posted November 16, 2007 Author Share Posted November 16, 2007 I tried calling them and they said they offer no support for their hosting packages. They wont tell me what that first param should be and I don't know how to find out. Additionally, I don't even know if that IS the problem or not as my php experience is rather limited. I don't know what to do. Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted November 16, 2007 Share Posted November 16, 2007 Go to your GoDaddy account and rummage through everything...you will find it eventually. If I remembered exactly where to go, I would tell you. I recall having a difficult time finding it though. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 16, 2007 Share Posted November 16, 2007 If they don't offer support for their hosting packages, I'd dump them. Quote Link to comment Share on other sites More sharing options...
marcus Posted November 16, 2007 Share Posted November 16, 2007 GoDaddy is a PoS. But just login to your domain name's control panel, and click Databases. There you should see a list of databases along with what type they are, click the database name, it will show you the host and name. For GoDaddy, host and username for mySQL connections are the same. Quote Link to comment Share on other sites More sharing options...
flash gordon Posted November 16, 2007 Author Share Posted November 16, 2007 Oh, I agree. I'm was just doing some flash work and was forced to use GoDaddy. Is this what you mean: MySQL Database InformationStatus:SetupHost Name:p41mysql103.secureserver.netDatabase Name:Phil01 Database Version:4.1 Description:Not SetUser Name:Phil01 Does that tell you anything? Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 16, 2007 Share Posted November 16, 2007 Ok, you probably need to be logged into your GoDaddy account... Go to 'My Account'. In the far right side of the top nav bar is a question mark (?). Click it to go to the Knowledge Center (url ends up help.godaddy.com). In the search box, type in mysql server. Under result 21, for linux or windows shared hosting, is the directions for setting up and connecting to your mysql database. Note: Once you have set up a database for your account' date=' you can click on the Pencil icon next to the name of your database to find your host name information.[/quote'] PhREEEk Quote Link to comment Share on other sites More sharing options...
marcus Posted November 16, 2007 Share Posted November 16, 2007 Yes. $connect = mysql_connect("p41mysql103.secureserver.net","Phil01","yourpassword") or die("Cannot connect to database server " . mysql_error()); $db = mysql_select_db("Phil01",$connect); Quote Link to comment Share on other sites More sharing options...
flash gordon Posted November 16, 2007 Author Share Posted November 16, 2007 Thanks guys! I got it connecting now. That's awesome! Unforntualely I have a bunch of SQL errors now that I don't get anywhere else, but it is working. yea! You guys rock. Ever need some flash help come on over to actioscript.org! If anyone see something that sticks out....let me know about this error. /** * Used for testing */ $_POST['position'] = '123,456'; $_POST['name'] = 'Julie'; $_POST['lit'] = 'true'; $ip = $_SERVER['REMOTE_ADDR']; // if only position is posted if( !isset($_POST['lit']) && !isset($_POST['name']) && isset($_POST['position']) ) { // add data to $position = $_POST['position']; $sql = "INSERT INTO $table VALUES('', '$ip', '$position', '', '')"; mysql_query($sql) or die(mysql_error()); } // if position and name is set, add name else if( !isset($_POST['lit']) && isset($_POST['name']) && isset($_POST['position']) ) { $position = $_POST['position']; $name = $_POST['name']; // find which row to update $sql = "SELECT * FROM $table WHERE ip = '$ip' AND position = '$position'"; // <-- error here? $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); $id = $row['id']; // update the row $sql = "UPDATE $table SET name = '$name' WHERE id = '$id'"; mysql_query($sql) or die(mysql_error()); } You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ip = '64.193.88.5' AND position = '123,456'' at line 1 Quote Link to comment Share on other sites More sharing options...
revraz Posted November 16, 2007 Share Posted November 16, 2007 Is $table defined on this page? Quote Link to comment Share on other sites More sharing options...
flash gordon Posted November 16, 2007 Author Share Posted November 16, 2007 yea, i just didn't include the full code. If you want everything here it is: <?php //Connect To Database //$hostname='p50mysql55.secureserver.net'; $hostname='p41mysql103.secureserver.net'; $username='mycandle'; $password='******'; //$dbname='mycandle'; $dbname='Phil01'; $username='Phil01'; $usertable='your_tablename'; $yourfield = 'your_field'; $tale = "candledata"; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); /** * Used for testing */ $_POST['position'] = '123,456'; $_POST['name'] = 'Julie'; $_POST['lit'] = 'true'; $ip = $_SERVER['REMOTE_ADDR']; // if only position is posted if( !isset($_POST['lit']) && !isset($_POST['name']) && isset($_POST['position']) ) { // add data to $position = $_POST['position']; $sql = "INSERT INTO $table VALUES('', '$ip', '$position', '', '')"; mysql_query($sql) or die(mysql_error()); } // if position and name is set, add name else if( !isset($_POST['lit']) && isset($_POST['name']) && isset($_POST['position']) ) { $position = $_POST['position']; $name = $_POST['name']; // find which row to update $sql = "SELECT * FROM $table WHERE `ip` = '$ip' AND `position` = '$position'"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); $id = $row['id']; // update the row $sql = "UPDATE $table SET name = '$name' WHERE id = '$id'"; mysql_query($sql) or die(mysql_error()); } // if all data is set else if (isset($_POST['lit']) && isset($_POST['name']) && isset($_POST['position']) ) { $position = $_POST['position']; $lit = ($_POST['lit'] == "true") ? 1 : 0; // find which row to update $sql = "SELECT * FROM $table WHERE `ip` = '$ip' AND `position` = '$position'"; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); $id = $row['id']; // update the row $sql = "UPDATE $table SET lit = '$lit' WHERE id = '$id'"; mysql_query($sql) or die(mysql_error()); } mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted November 16, 2007 Share Posted November 16, 2007 $tale = "candledata"; Typo in the post or in the code? Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 16, 2007 Share Posted November 16, 2007 $tale will need a 'b' in it = D $table PhREEEk Quote Link to comment Share on other sites More sharing options...
flash gordon Posted November 16, 2007 Author Share Posted November 16, 2007 Wow....thanks guys! In the midst of making soo many databases and trying different stuff, I got sloppy. Sorry I can't help out around here any, but as you can see my PHP is rather bad. If you every need some flash help, come on over to AS[org] You guys rock! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.