Jump to content

Stevis2002

Members
  • Posts

    98
  • Joined

  • Last visited

    Never

Everything posted by Stevis2002

  1. Thanks very much for helping me with this Jon. My statement now looks like this, mysql_select_db($database_localhost, $localhost); mysql_query("SELECT Images FROM testimonials WHERE Testimonial_Id=%s"); $result = mysql_query("SELECT Images FROM testimonials WHERE Testimonial_Id=%s"); while($row = mysql_fetch_array($result)) { $img_dir = 'uploaded_images/'; $image_name = $row_RecordSet1['Images']; echo $image_name; die(); if ((isset($_GET['del'])) && ($_GET['del'] != "")) { unlink($img_dir . $row['Images']); // unlink($img_dir.$image_name); } but it is giving me this error..... Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\AdministrationAreaSublime\testimonials.php on line 36
  2. Thanks for that but the row with the images contact is the row which holds the url information. The file is on the server and that is wjhat i cannot do
  3. By the way, the db connection is opened at the top of the page
  4. Thanks for all the help, but still blank page mysql_select_db($database_localhost, $localhost); mysql_query("SELECT Images FROM testimonials WHERE Testimonial_Id=%s"); $img_dir = 'uploaded_images/'; $image_name = $row_RecordSet1['Images']; echo $image_name; die(); if ((isset($_GET['del'])) && ($_GET['del'] != "")) { unlink($img_dir . $row['Images']);
  5. Returns a blank page only. The row Images in the database stores /uploaded_images/xxxx.jpg. It gets from the image name from the image the user uploads
  6. Hi all, Please can somebody help me sort my script out? I want it to delete the sql contents in the chosen table, and delete the file stored on server at the same time. URL for server is stored in the database. Everything works except for when it comes to deleting the file off the server. I just can't work it out/get my head around it. Many Thanks in advance if you can help, Steve <?php require_once('Connections/localhost.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $query_Recordset1 = "SELECT Images FROM testimonials WHERE Testimonial_Id=%s"; $img_dir = 'uploaded_images/'; $image_name = $row_RecordSet1['Images']; if ((isset($_GET['del'])) && ($_GET['del'] != "")) { unlink($img_dir . $row['Images']); // unlink($img_dir.$image_name); $deleteSQL = sprintf("DELETE FROM testimonials WHERE Testimonial_Id=%s", GetSQLValueString($_GET['del'], "int")); mysql_select_db($database_localhost, $localhost); $Result1 = mysql_query($deleteSQL, $localhost) or die(mysql_error()); $deleteGoTo = "index.php"; if (isset($_SERVER['QUERY_STRING'])) { $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?"; $deleteGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $deleteGoTo)); } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_localhost, $localhost); $query_Recordset1 = "SELECT * FROM testimonials ORDER BY SortOrder ASC"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sub-Lime Renovations Admin Area - View Testimonials</title> </head> <body> <div align="center"> <h1><strong>Sub-Lime Renovations Administration Area</strong></h1> </div> <p align="center"><a href="index.php">Admin Home</a> | <a href="add_testimonials.php">Add Testimonials</a></p> <p> </p> <p> </p> <table border="1" align="center" cellpadding="1" cellspacing="1"> <tr> <td>Customer Name</td> <td>Town</td> <td>Testimonial</td> <td>Sort Order</td> <td>Images</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Recordset1['CustomerName']; ?></td> <td><?php echo $row_Recordset1['Town']; ?></td> <td><?php echo $row_Recordset1['Testimonial']; ?></td> <td><?php echo $row_Recordset1['SortOrder']; ?></td> <td><img width ="100" height="100" src="/AdministrationAreaSublime/<?php echo $row_Recordset1['Images']; ?>" alt="" /></td> <td><a href="edit_testimonials.php?Testimonial_Id=<?php echo $row_Recordset1['Testimonial_Id']; ?>">Edit</a></td> <td><input type="button" name="del" id="del" value="Delete" onClick="document.location.href='testimonials.php?del=<?php echo $row_Recordset1['Testimonial_Id']?>'" /></td></tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> <p> </p> </body> </html> <?php mysql_free_result($Recordset1); ?>
  7. Barand....You my friend are a complete legend...a saint of all patient programmers!!! With a little messing, i got rid of the error statement completely...don't need it, due to the fact that if there is a problem, the script wont go onto the forwarding page anyway, so i will now there is a prob, as the script is just to enter the info into the db anyway, and only i will be doing that! I can manage the data layout and all that jazz myself for the users end. So, Thanks once more for the patience and understanding you have with us [s]dunces[/s] newbies. Steve
  8. Is the uploaddir path ok, or should it be a complete path? Thanks, Steve
  9. Changed the layout so that if there is an error then it dies, but it still enters the info into the db, it doesn't mention any error, but the image still isn't in the correct directory :( [code]     $uploaddir = '\plants';     $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);     if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir)) {         $insertSQL = sprintf("INSERT INTO plants (image_name, image_type, image_size, path, plant_name, plant_type, planting_months, blooming_season, plant_description) VALUES ('%s', '%s', '%s', '%s', %s, %s, %s, %s, %s)",     $fileImagename,     $fileImagetype,     $fileImagesize, $uploaddir,     GetSQLValueString($_POST['plant_name'], "text"),     GetSQLValueString($_POST['plant_type'], "text"),     GetSQLValueString($_POST['planting_months'], "text"),     GetSQLValueString($_POST['blooming_season'], "text"),     GetSQLValueString($_POST['plant_description'], "text"));     mysql_select_db($database_localhost, $localhost);     $Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());     $insertGoTo = "plants.php";     if (isset($_SERVER['QUERY_STRING'])) {     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";     $insertGoTo .= $_SERVER['QUERY_STRING'];     }     header(sprintf("Location: %s", $insertGoTo));     exit;     } else{         echo "There was an error uploading the file, please try again!";     } } ?> [/code]
  10. Thanks once again....I changed the image_name to name, but the code you mentioned is non existent now as i commented it out due to the header problem.
  11. [code] <?php $time_start = microtime(true); // Sleep for a while usleep(100); $time_end = microtime(true); $time = $time_end - $time_start; echo "Did nothing in $time seconds\n"; ?> [/code] PHP5
  12. Thanks again.....I have removed the message, but the page doesn't get forwarded on, and the image still isn't getting uploaded. [code]     mysql_select_db($database_localhost, $localhost);     $Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());     $insertGoTo = "plants.php";     if (isset($_SERVER['QUERY_STRING'])) {     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";     $insertGoTo .= $_SERVER['QUERY_STRING'];     }     header(sprintf("Location: %s", $insertGoTo));     exit; [/code]
  13. An easier way might be to add the code into a function. EG, the function which sends all the info to the db, should post an error if there is a problem, which makes your if - else statements. So under the actual process for posting the info into the db, you could add the process for mailing a email to yourself, and if anythink fails, then it will give the user the standard db error
  14. Thanks for the help. I had a permissions and directory error after that, but i sorted that one out, but then i get this error and i don't know what this means ... The file has been uploaded Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\admin\includes\add_plant.php:45) in C:\Program Files\xampp\htdocs\admin\includes\add_plant.php on line 69 BTW....All data is going into db correctly now, although the image still isn't being uploaded/moved.
  15. Try putting a / before the "crikey, and a / after the closing quotes
  16. Right then, Here is the output....Hope i placed it in right place! The file has been uploadedINSERT INTO plants (image_name, image_type, image_size, path, plant_name, plant_type, planting_months, blooming_season, plant_description) VALUES ('blush_delieux.jpg', 'image/pjpeg', '4006', '/plants/', ''test'', ''test'', ''test'', ''test'', ''test'')You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test'', ''test'', ''test'', ''test'', ''test'')' at line 1 Thatnks for that btw....didn't know about that little trick :)
  17. Close the quotes.. [code]$data = mysql_query("SELECT * FROM user) [/code] to [code]$data = mysql_query("SELECT * FROM user")[/code]
  18. Thanks mate, Giving me yet another error now, and this time i have absolutely zero idea what's causing it :( The file has been uploadedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test'', ''test'', ''test'', ''test'', ''test'')' at line 1
  19. Yes, so i would have to add a [code]$uploaddir[/code]?
  20. [code] $data = mysql_query("SELECT * FROM "user") [/code] should be [code] $data = mysql_query("SELECT * FROM user) [/code] I think.
  21. Thanks for that, although it still returns that there are too few arguments in the sprintf function. Is this because there is no information being collected about the image size, path, name etc? Thanks, Steve
  22. Yes, i should think that you could do an 'if' statement which checks to see if the id, (which hopefully is auto incremented when a new record is inserted), has gone up one, and then in the statement put the mail function. Something like that?
  23. Been looking and messing now and still can't fatham it out. God, i've got a lot to learn still lol
  24. Ok, by changing [code] $fileImagename = $_FILES['userfile']['name'];     $fileImagesize = $_FILES['userfile']['size'];     $fileImagetype = $_FILES['userfile']['type']; [/code] to [code]     $fileImagename = $_FILES['userfile']['image_name'];     $fileImagesize = $_FILES['userfile']['image_size'];     $fileImagetype = $_FILES['userfile']['image_type']; [/code] I got rid of the error, but now i have an sql error because i don't think it is storing the path, image_name, image_size, or image_type. How can i change this? The file has been uploadedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , NULL, 'info', 'info', 'info', 'info', 'info')' at line 1
×
×
  • 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.