nebraskageek Posted November 15, 2009 Share Posted November 15, 2009 Hello, I own Nebraska Geek, and I am also the webmaster. We have tried to implement our news into a MySQL database. Database table (news) consists of postTitle,postBody,author,date,type (all VARCHARS) and postNumber (INT). below is the i used to get it: $dbhost = "nebraskageek.fatcowmysql.com"; $dbname = "beta"; $dbuser = "gulliccj"; $dbpass = "pepper8"; mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $query = "SELECT * FROM news"; $result = mysql_query($query); $ii = mysql_num_rows($result)-1; for($i = 0; $i<=$ii;$i++) { //2nd time through returns: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) $query2 = "select * from news where postNumber='$i'"; $result2=mysql_query($query2)or die(mysql_error()); $row = mysql_fetch_array( $result2 ); mysql_close(); $pt=$row['postTitle']; $pb=$row['postBody']; $a=$row['author']; $d=$row['date']; $t=$row['type']; $n =$row['postNumber']; echo "<hr><div id='title'>$pt</div> <br>". "<div id='post'>$pb <hr>". "$a $d <br>Category: $t </div><hr>"; } mysql_close(); but it returns:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) its second time through the loop, and displays a blank post...why? thanks so much for reading. Quote Link to comment https://forums.phpfreaks.com/topic/181610-help-with-phpmysql/ Share on other sites More sharing options...
JAY6390 Posted November 15, 2009 Share Posted November 15, 2009 By the looks of it you don't have mysql enabled in php Quote Link to comment https://forums.phpfreaks.com/topic/181610-help-with-phpmysql/#findComment-957935 Share on other sites More sharing options...
alex3 Posted November 15, 2009 Share Posted November 15, 2009 Err... I'd star out those db connection details... Quote Link to comment https://forums.phpfreaks.com/topic/181610-help-with-phpmysql/#findComment-957992 Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2009 Share Posted November 15, 2009 The error message means that the $dbhost name you are using is not that of an actual mysql server. On shared web hosting it will be something like mysqlx.yourwebhost.com You would need to check with your web host to be sure what it is on your server. Your database management tool (where you created the database, username, and password) typically displays the correct mysql server host name to use in the connection. Quote Link to comment https://forums.phpfreaks.com/topic/181610-help-with-phpmysql/#findComment-957993 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.