steelmanronald06 Posted March 12, 2006 Share Posted March 12, 2006 [code]<?php$title = ":. Edit News";require_once($_SERVER['DOCUMENT_ROOT'].'/includes/top.php');$newsid = isset($_GET['news_id']) ? $_GET['news_id'] : NULL;/* Connect To The Database Via Including It */require_once($_SERVER['DOCUMENT_ROOT'].'/includes/db.php');// Get Secure Access Levels$secure_username = $_SESSION['username'];$securequery=mysql_query("SELECT * FROM `users` where username='$secure_username'");$securerow=mysql_fetch_array($securequery);$access_level=$securerow['user_level'];// Redirect All Restricted Usersif($access_level == 0 || $access_level == 1) { echo "<p>You don't have permission to view this page. If you feel you have reached this page by error, please contact the administrator.</p>";}// If They Have Permission, We Let Them Postif($access_level == 2 || $access_level == 3 || $access_level == 4) { // Get The Posters Username $news_username = $_SESSION['username']; if (isset($_POST['submit'])) { // Assign Variables $name = strip_tags(trim($_POST['name'])); $subject = strip_tags(trim($_POST['subject'])); $message = $_POST['message']; $date = date("D m/d/Y - g:ia"); $postquery = "UPDATE news SET name='$name', subject='$subject', message='$message', date='$date' WHERE id='$newsid'"; mysql_query($postquery) or die(mysql_error()); mysql_close(); echo "News Updated!"; } /* Time To Select The News From The Database */ $query = "SELECT * FROM news WHERE id='$newsid'"; $result = mysql_query($query); $result_array = mysql_fetch_assoc($result); ?> <p> <form name="news" method="post" action="<? echo $PHP_SELF ?>"> <input name="name" type="hidden" value="<? echo $news_username ?>"> Subject: <input type="text" name="subject" value="<? echo("{$result_array['subject']}"); ?>"><br><br> Message:<br> <textarea name="message" cols="60" rows="15"><? echo("{$result_array['message']}"); ?></textarea> <br><br> <input type="submit" name="submit" value="Edit" style="cursor:pointer"> <input type="reset" name="reset" value="Clear" style="cursor:pointer"> </form> </p> <?php}else{ echo "<p>You have failed to pass both security checks. Your actions have been logged and reported to the site administrator. If you believe you have recieved this error by mistake, please contact the webmaster.</p>";}require_once($_SERVER['DOCUMENT_ROOT'].'/includes/bot.php');?>[/code][!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/netgeekz.net/news/edit.php on line 54Warning: mysql_query(): A link to the server could not be established in /home/www/netgeekz.net/news/edit.php on line 54Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/netgeekz.net/news/edit.php on line 55[/quote]Any way to fix the error? Quote Link to comment https://forums.phpfreaks.com/topic/4758-mysql-errors/ Share on other sites More sharing options...
hitman6003 Posted March 12, 2006 Share Posted March 12, 2006 Well, since the error is happening in your included db.php file, there isn't anything we can do to help you fix your code.However, since the error plainly states that you can not connect to mysql through a socket, I would say you could probably fix this by not trying to connect to mysql through a socket. Quote Link to comment https://forums.phpfreaks.com/topic/4758-mysql-errors/#findComment-16696 Share on other sites More sharing options...
steelmanronald06 Posted March 12, 2006 Author Share Posted March 12, 2006 I am connected to the database the same way everywhere else. this is the only script on my site that isn't working. Quote Link to comment https://forums.phpfreaks.com/topic/4758-mysql-errors/#findComment-16700 Share on other sites More sharing options...
hitman6003 Posted March 12, 2006 Share Posted March 12, 2006 There has to be something different about that particular page if you are using that same script from your other pages.The only other thing I can offer is a link or two:[a href=\"http://www.tech-recipes.com/mysql_tips762.html\" target=\"_blank\"]http://www.tech-recipes.com/mysql_tips762.html[/a][a href=\"http://www.modwest.com/help/kb6-220.html\" target=\"_blank\"]http://www.modwest.com/help/kb6-220.html[/a]But I don't know if it will help or not. Quote Link to comment https://forums.phpfreaks.com/topic/4758-mysql-errors/#findComment-16702 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.