Jump to content

[SOLVED] Can't connect to local MySQL server through socke


adam291086

Recommended Posts

What does this mean. The code below is where its occuring

 

Error retrieving records adam: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

 

 

<?php
("config.php");
// Has album been updated?
if ( $_POST['edit'] ){
if ( empty($_POST['photo_title']) || empty($_POST['photo_desc'])){
$msg = "Please complete all required fields!<br /><a href='edit_photos.php'>Go Back</a>";
displayPage( $msg, "Error Updating Photo!");
die();
}
con;
// Insert updated record into DB
$sql = "UPDATE photos SET photo_title = '" . addslashes($_POST['photo_title']) . "', photo_desc = '" . addslashes($_POST['photo_desc']) . "' WHERE photo_id = " . $_POST['photo_id'];
$result = @mysql_query( $sql ) or die("Error inserting record: " . mysql_error());
if ($result){
$msg = "Photo updated successfully!<br /><a href='index.php'>Return to Admin Menu</a>";
displayPage($msg, "Photo Updated Successfully!");
die();
}
con;
// Retrieve album information
$sql = "SELECT photo_id, photo_title, photo_desc FROM photos WHERE photo_id = " . addslashes($_GET['photo_id']);
$result = @mysql_query( $sql ) or die("Error retrieving record: " . mysql_error());
while($row = mysql_fetch_array( $result )){
// Display edit page
$msg .= "<form action=\"edit_photos.php\" method=\"post\">\n";
$msg .= "<table width=\"60%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n";
$msg .= "<tr>\n<td>Photo Title:</td>\n<td><input name=\"photo_title\" type=\"text\" id=\"photo_title\" size=\"40\" value=\"" . $row['photo_title'] . "\"></td>\n</tr>\n";
$msg .= "<tr>\n<td>Photo Description:</td>\n<td><textarea name=\"photo_desc\" cols=\"30\" rows=\"4\" id=\"photo_desc\">" . $row['photo_desc'] . "</textarea></td>\n</tr>\n";
$msg .= "<tr>\n<td><input type=\"hidden\" name=\"edit\" value=\"1\"><input type=\"hidden\" name=\"photo_id\" value=\"" . addslashes($_GET['photo_id']) . "\"></td>\n";
$msg .= "<td><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Continue\">";
$msg .= "<a href=\"del_photos.php?photo_id=" . addslashes($_GET['photo_id']) . "\">Delete</a>";
$msg .= "</td>\n</tr>\n</table>\n</form>";
$photo_title = $row['photo_title'];
}
displayPage($msg, "Editing Photo " . $photo_title . ":"); 
// Display album summaries
} elseif ( !$_GET['photo_id'] ){
con;
// Retrieve all album information 
$sql = "SELECT photos.photo_id, photos.photo_title, albums.album_cover FROM photos, albums
WHERE photos.album_id = albums.album_id";
$result = @mysql_query( $sql ) or die( "Error retrieving records: " . mysql_error() );
$i = 0;
while($row = mysql_fetch_array($result)){ 
if (( $i % IMAGE_DISPLAY ) == 0 && ( $i != 0 )){
$msg .= ("</tr>\n<tr>");
}
$msg .= ("<td>" . ($i + 1) . ". <a href='edit_photos.php?photo_id=" . $row['photo_id'] . "'>");
$msg .= ($row['photo_title'] . "<br /><img src=\"../" . $row['album_cover'] . "\" /></td>\n"); 
$i++;
}
displayPage( $msg, "Edit Photos", false );
} 
?>

Link to comment
Share on other sites

Thanks for that, its now working. But there is one problem. Instead of taking every photo from the database for that album it only takes the recently upload picture. It then displays that picture a number of time depending on the number of images stored in the database relating to that album. Any ideas

 

<?php
include_once("config.php");
// Has album been updated?
if ( $_POST['edit'] ){
if ( empty($_POST['photo_title']) || empty($_POST['photo_desc'])){
$msg = "Please complete all required fields!<br /><a href='edit_photos.php'>Go Back</a>";
displayPage( $msg, "Error Updating Photo!");
die();
}
con;
// Insert updated record into DB
$sql = "UPDATE photos SET photo_title = '" . addslashes($_POST['photo_title']) . "', photo_desc = '" . addslashes($_POST['photo_desc']) . "' WHERE photo_id = " . $_POST['photo_id'];
$result = @mysql_query( $sql ) or die("Error inserting record: " . mysql_error());
if ($result){
$msg = "Photo updated successfully!<br /><a href='index.php'>Return to Admin Menu</a>";
displayPage($msg, "Photo Updated Successfully!");
die();
}
} else if ( !$_POST['edit'] && !empty($_GET['photo_id'])){
con;
// Retrieve album information
$sql = "SELECT photo_id, photo_title, photo_desc FROM photos WHERE photo_id = " . addslashes($_GET['photo_id']);
$result = @mysql_query( $sql ) or die("Error retrieving record: " . mysql_error());
while($row = mysql_fetch_array( $result )){
// Display edit page
$msg .= "<form action=\"edit_photos.php\" method=\"post\">\n";
$msg .= "<table width=\"60%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n";
$msg .= "<tr>\n<td>Photo Title:</td>\n<td><input name=\"photo_title\" type=\"text\" id=\"photo_title\" size=\"40\" value=\"" . $row['photo_title'] . "\"></td>\n</tr>\n";
$msg .= "<tr>\n<td>Photo Description:</td>\n<td><textarea name=\"photo_desc\" cols=\"30\" rows=\"4\" id=\"photo_desc\">" . $row['photo_desc'] . "</textarea></td>\n</tr>\n";
$msg .= "<tr>\n<td><input type=\"hidden\" name=\"edit\" value=\"1\"><input type=\"hidden\" name=\"photo_id\" value=\"" . addslashes($_GET['photo_id']) . "\"></td>\n";
$msg .= "<td><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Continue\">";
$msg .= "<a href=\"del_photos.php?photo_id=" . addslashes($_GET['photo_id']) . "\">Delete</a>";
$msg .= "</td>\n</tr>\n</table>\n</form>";
$photo_title = $row['photo_title'];
}
displayPage($msg, "Editing Photo " . $photo_title . ":"); 
// Display album summaries
} elseif ( !$_GET['photo_id'] ){
con;
// Retrieve all album information 
$sql = "SELECT photos.photo_id, photos.photo_title, albums.album_cover FROM photos, albums
WHERE photos.album_id = albums.album_id";
$result = @mysql_query( $sql ) or die( "Error retrieving records: " . mysql_error() );
$i = 0;
while($row = mysql_fetch_array($result)){ 
if (( $i % IMAGE_DISPLAY ) == 0 && ( $i != 0 )){
$msg .= ("</tr>\n<tr>");
}
$msg .= ("<td>" . ($i + 1) . ". <a href='edit_photos.php?photo_id=" . $row['photo_id'] . "'>");
$msg .= ($row['photo_title'] . "<br /><img src=\"../" . $row['album_cover'] . "\" /></td>\n"); 
$i++;
}
displayPage( $msg, "Edit Photos", false );
} 
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.