Jump to content


Photo

MySQL Errors


  • Please log in to reply
3 replies to this topic

#1 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 12 March 2006 - 04:07 PM

<?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 Users
if($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 Post
if($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');
?>

[!--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 54

Warning: mysql_query(): A link to the server could not be established in /home/www/netgeekz.net/news/edit.php on line 54

Warning: 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?

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 12 March 2006 - 04:17 PM

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.

#3 steelmanronald06

steelmanronald06
  • Staff Alumni
  • Advanced Member
  • 2,004 posts
  • LocationOk

Posted 12 March 2006 - 04:23 PM

I am connected to the database the same way everywhere else. this is the only script on my site that isn't working.

#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 12 March 2006 - 04:34 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users