adam291086 Posted October 1, 2007 Share Posted October 1, 2007 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 ); } ?> Quote Link to comment Share on other sites More sharing options...
shocker-z Posted October 1, 2007 Share Posted October 1, 2007 does /var/lib/mysql/mysql.sock exist? can you connect to your mysql database remotley? what bout from command line also? more a system/server issue than PHP Liam Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 1, 2007 Author Share Posted October 1, 2007 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 ); } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted October 1, 2007 Share Posted October 1, 2007 Your code is seriously hard to read because of your distinct lack of logical indentation. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted October 1, 2007 Author Share Posted October 1, 2007 I know but i am having to use notpad at the mo as i am at work 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.