Jump to content

mike12255

Members
  • Posts

    439
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mike12255

  1. crap its back to saying nothing, its suposed to appear under the video player: http://sgi-clan.info/gnomes/images.php
  2. it said: 1 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sgiclan/public_html/gnomes/images.php on line 469
  3. I tried what you mates suggested so i've been editing it, and got the following error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sgiclan/public_html/gnomes/images.php on line 466 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sgiclan/public_html/gnomes/images.php on line 467 <?php error_reporting(E_ALL); $findimage = mysql_query ("Select * FROM `phpbb_files`") or die(mysql_error()); echo mysql_num_rows($findimage['shortname']); while ($row = mysql_fetch_array($findimage['shortname'])){ $image ="uploads/"; $image .= $row['shortname']; echo "<img src=\"".$image."\" alt=\"Image can not be found\" />"; } ?>
  4. I created some code to grab and image from X folder and by X name (both combined into one var called $image) i get no errors when i view the page, but the images don't appear. I tried echoing $name and it showed up properly as uploads/image.gif heres my code : <?php $findimage = mysql_query ("Select * FROM `phpbb_files`"); while ($row = mysql_fetch_array($findimage)){ $image ="uploads/"; $image .= $row['shortname']; ?> <img src= <?=$image?> /> <?php }?>
  5. yeah i know i fixed it already - thanks to your previous message. Thanks alot!
  6. i just re-uploaded it. and tested it again. The same error so i know its the right script. Anyway i got to get to bed i got an exam in 8 hrs. Ill check this thread in the morning
  7. inside the () is the field name inside the table were i want the data inserted. Thats wrong? And the entire script is posted. Its the first bit of code i posted.
  8. i dont even know what the error means @Crayon Violent yes im sure im running that script
  9. I got an image upload script, and when somone uploads an image, i want it to save the name + extension in the databse (along with an auto increomenting id) I have my database already and my script is as follows: <?php include "connect.php"; //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","100"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="uploads/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully! Try again!</h1>"; $insert ="INSERT INTO `phpbb_files`(`shortname` ) VALUES (`$image_name`)"; mysql_query($insert) or die(mysql_error()); } ?> <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" --> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> Im getting the following error after clicking upload: i think its somewhere around this code thats causing the troubles: <?php if(isset($_POST['Submit']) && !$errors) { echo "<h1>File Uploaded Successfully! Try again!</h1>"; $insert ="INSERT INTO `phpbb_files`(`shortname` ) VALUES (`$image_name`)"; mysql_query($insert) or die(mysql_error()); } ?>
  10. Ok, well i know a guy that is an amazing programmer and he helped me rewrite that code in two lines and save my database space: $newitems = mysql_query("SELECT * FROM forumtutorial_posts ORDER BY realtime DESC LIMIT 4"); // for the newest posts. while($row = mysql_fetch_array($newitems)) { print($row["postid"] . " " . $row["author"] . " " . $row["time"]); } Thanks to Precision(my friend - not on this forum)
  11. yeah i know i saw your message about doing it in php my admin earlier but im getting ready for work, figured i'd do it when i got home
  12. This kind of worked: if ($num_rows > 4){ for ($counter=10; $num_rows > 4; $counter++){ $getdate = "SELECT MAX(date) AS date FROM `newitems`"; $dateresult = mysql_query($getdate) or die (mysql_error()); $delete = mysql_fetch_assoc($dateresult); $todelete = "DELETE FROM newitems WHERE date = '{$delete['date']}'"; mysql_query($todelete); but it deleted everything instead of leaving me with the four newest
  13. yeah i added it in, already and it still dosnt work: if ($num_rows > 4){ for ($counter=10; $num_rows > 4; $counter++){ $getdate = "SELECT MAX(date) FROM `newitems`" ; $dateresult = mysql_query($getdate) or die (mysql_error()); $delete = mysql_fetch_assoc($dateresult); $todelete = "DELETE FROM newitems WHERE date = {$delete['date']}";
  14. @ gevans Dont say sorry mate, your helping me. P.S it didnt work @Maq thanks for the explination mate
  15. I have the following code: $insertnew="INSERT INTO newitems (title,author,date,url) VALUES ('$subject','$name','$thedate','$url[0]')"; mysql_query($insertnew) or die ("Could insert the new data!"); $amount= mysql_query("SELECT * FROM newitems"); $num_rows = mysql_num_rows($amount); if ($num_rows > 4){ for ($counter=10; $num_rows > 4; $counter++){ $getdate = "SELECT MAX(date) FROM `newitems`" ; $dateresult = mysql_query($getdate) or die (mysql_error()); $delete = mysql_fetch_row($dateresult); $todelete = "DELETE FROM newitems WHERE date = $delete"; mysql_query($todelete); } } anyway i cant get it to delete i know its passing for if statment because i echo'd my $num_rows and it was greater then four. Any ideas?
  16. well i've never even heard of DESC soo i guess the other way?
  17. ok, so would that put oldest as first or as last?
  18. sorry, just wrote an exam and school and got back, so lets say that the database looked like below, probually wont but something similar: you guys say theres a way to deleate it using the date? btw idk if that is setup right im not the best in mysql
  19. I have a database, that only contains 4 things inside it. Is there a way that when i go to add a new entry to it, searches for the oldest entry in 'headernews' and deleates it?
  20. i dont think your connected to a database? try setting those variables after your connected
  21. echo <<<HTML You can put all the HTML you want here HTML; you do that to enter html into a php document?
×
×
  • 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.