Jump to content

Darkwoods

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by Darkwoods

  1. hello guys i hope someone can help me with this i have made a table with list of categories and categories content table and its working just fine but the thing is i want to display the categories in drop down with categories content for example like this <select> <optgroup label="Cat1"> <option value="1">Dogs</option> <option value="2">Cat</option> </optgroup> <optgroup label="Cat2"> <option value="3">data1</option> <option value="4">data2</option> </optgroup> </select> could anybody help please thank you
  2. oops i can see the mistake now! i never ended it lol i always do this dumb mistake sorry include "inc/contactus.php";
  3. im trying to make an if then include but it is not working my question is can if and include work together? <?php $id = $_GET['id']; $result = mysql_query("SELECT * FROM pages WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { echo '<div class="'; echo $row['lang']; echo '">'; echo '<div>'; echo $row['content']; echo '</div>'; echo '</div>'; if($id == '2') { echo '<div>'; include "inc/contactus.php" echo '</div>'; } } ?>
  4. i ment i want it to take information only when the file input is not empty and if it is empty i want it to keep the same data in the mysql table
  5. im trying to change my edit page where i upload my thumbnails.. what im trying do is when the image upload form/input is empty for example i dont want it to change because now when i try to edit only the text on the edit page and update it remove the file name from mysql table and here where my problem is wan it to take the information from the file/input when i got somethingin it how do i do that? <?php include "../admin/inc/header.php"; $id = $_GET['id']; if(isset($_POST['submit'])) { $bkname = $_POST['bkname']; $content = $_POST['content']; $thefile2=$_FILES['thefile']['name']; if(!$bkname){ echo "Error: Page Name is a required field. Please fill it."; exit(); } if(!$thefile2){ echo $row['thefile']; } $result = mysql_query("UPDATE latest SET thefile='$thefile2', bkname='$bkname', content='$content' WHERE id='$id' ",$connect) or die(mysql_error()); echo "<b>Successfully Edited</b>"; // echo "<meta http-equiv=Refresh content=2;url=index.php>"; } elseif($id) { $result = mysql_query("SELECT * FROM latest WHERE id='$id' ",$connect) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $bkname = $row['bkname']; $content = $row['content']; $thefile2 = $row['thefile']; ?> <form name='form1' method='post' action='<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?>' enctype='multipart/form-data'> <input type="hidden" name="id" value="<?php echo $row['id'];?>"> Book Name: <input name="bkname" size="40" maxlength="255" value="<?php echo $bkname; ?>" /><br /> Book Info: <textarea name="content"><?php echo $content; ?></textarea><br> Select File: <input type='file' name='thefile'><br> <input type="hidden" name="thefile" value="<?php echo $row['thefile'];?>"> <input type='submit' name='submit' value='upload'><br /><br /> <?php echo '<img src="../uploads/thumbs/thumb'. $row['thefile'] . '" hspace="5" vspace="5" align="left" />'; } echo '</form>'; $new_height=175; $new_width=175; $allowed_types = array( 'image/pjpeg', 'image/gif', 'image/png', 'image/jpeg'); if(in_array($_FILES['thefile']['type'], $allowed_types)) { copy ($_FILES['thefile']['tmp_name'], $_FILES['thefile']['name']) or die ("Could not copy"); echo "Name: ".$_FILES['thefile']['name'].""; echo "Size: ".$_FILES['thefile']['size'].""; echo "Type: ".$_FILES['thefile']['type'].""; $imagefile=$_FILES['thefile']['name']; list($width, $height) = getimagesize($_FILES['thefile']['name']); $image_p = imagecreatetruecolor($new_width,$new_height); if ($_FILES['thefile']['type'] == "image/gif") { $img = @imagecreatefromgif($imagefile); imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $thename=$_FILES['thefile']['name']; $thenames="thumb$thename"; $location="thumbs/$thenames"; imagegif($image_p,$location, 100); } else { $img = @imagecreatefromjpeg($imagefile); imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $thename=$_FILES['thefile']['name']; $thenames="thumb$thename"; $location="thumbs/$thenames"; imagejpeg($image_p,$location, 100); } } else { print "<br>Only Gifs and Jpegs are supported. Back to <A href='../admin/test.php'>Control Panel</a>"; } } include "../admin/inc/footer.php"; ?>
  6. Duplicate entry '0' for key 1 must be something with the id?
  7. how do i send thumb file name to my database here is the thumbnail creator page <?php include "../admin/inc/header.php"; if(isset($_POST['submit'])) { $new_height=100; $new_width=100; $allowed_types = array( 'image/pjpeg', 'image/gif', 'image/png', 'image/jpeg'); if(in_array($_FILES['thefile']['type'], $allowed_types)) { copy ($_FILES['thefile']['tmp_name'], $_FILES['thefile']['name']) or die ("Could not copy"); echo "Name: ".$_FILES['thefile']['name'].""; echo "Size: ".$_FILES['thefile']['size'].""; echo "Type: ".$_FILES['thefile']['type'].""; $imagefile=$_FILES['thefile']['name']; list($width, $height) = getimagesize($_FILES['thefile']['name']); $image_p = imagecreatetruecolor($new_width,$new_height); if ($_FILES['thefile']['type'] == "image/gif") { $img = @imagecreatefromgif($imagefile); imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $thename=$_FILES['thefile']['name']; $thenames="thumb$thename"; $location="thumbs/$thenames"; imagegif($image_p,$location, 100); } else { $img = @imagecreatefromjpeg($imagefile); imagecopyresampled($image_p, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); $thename=$_FILES['thefile']['name']; $thenames="thumb$thename"; $location="$thenames"; imagejpeg($image_p,$location, 100); } } else { print "<br>Only Gifs and Jpegs are supported. Back to <A href='../admin/test.php'>Control Panel</a>"; } } include "../admin/inc/footer.php"; ?> i tried with this code but without any luck $name=$_POST['name']; $thefile2=$_FILES['thefile']['name']; //Writes the information to the database $result = mysql_query("INSERT INTO latest (thefile, name) VALUES ('$thefile2','$name')",$connect);
  8. im trying to make a delete page but i want a code that ask the user if he/she are sure about deleting it.. if yes it will delete if no it wont! can anybody give any hint on where to start or help me doing it? here is the code i got a very simple and basic one... <?php include "inc/header.php"; $id = $_GET['id']; $result = mysql_query("DELETE FROM news WHERE id='$id' ",$connect); echo "<b>Deleted!"; //header("location: index.php"); // echo "<meta http-equiv=Refresh content=1;url=index.php>"; include "inc/footer.php"; ?>
  9. THANK YOU solved this little word 'LIMIT' killed me im sure i wont forget it now thank you
  10. hi im trying to make a 5 limit loops for this code but without any success can anybody help plz
  11. thanks do i put it any where in the page and it will work?
  12. hey.. when i upload a file named with spaces like for example ''file name.jpg'' it does not send the full name to mysql it just send 'file' plus to make a link to it it wont work because no % in spaces so the best thing is to put underscore in spaces but how what are codes thanks herer is the upload page <?php include "inc/header.php"; $id = $_GET['id']; if(isset($_POST['submit'])) { //global variables include "inc/variables.php"; $name=$_POST['name']; $pic=($_FILES['downl']['name']); $result = mysql_query("UPDATE contents SET title_en='$title_en', title_ar='$title_ar', en='$en', ar='$ar', cat='$cat', downl='$pic', name='$name' WHERE id='$id' ",$connect); echo "<b>Your post have been added successfully"; echo "<meta http-equiv=Refresh content=2;url=index.php>"; } //the directory where images will be saved $target = "uploads/downloads/"; $target = $target . basename( $_FILES['downl']['name']); //Writes the filedw to the server if(move_uploaded_file($_FILES['downl']['tmp_name'], $target)) { //Tells you if it the upload were done echo "The file ". basename( $_FILES['downl']['name']). " has been uploaded, and your information has been added to the directory"; } $result = mysql_query("SELECT * FROM contents WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { $title_ar = $row["title_ar"]; $title_en = $row["title_en"]; $en = $row["en"]; $ar= $row["ar"]; $cat= $row["cat"]; $name= $row["name"]; $pic= $row["downl"]; ?> <h3>:: Edit Uploaded Software</h3> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?>" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?php echo $row['id']?>"> <table border="0" cellspacing="4" cellpadding="4"> <tr> <td>Select Category:</td> <td colspan="2"><select name="cat"><option value="3">Download</option></select> </td> </tr> <tr> <td>Title:</td> <td ><input name="title_en" size="40" maxlength="255" value="<?php echo $title_en; ?>"></td> <td><input name="title_ar" size="40" maxlength="255" value="<?php echo $title_ar; ?>"></td> </tr> <tr> <td>Content:</td> <td><textarea name="en" rows="7" cols="30"><?php echo $en; ?></textarea></td> <td><textarea name="ar" rows="7" cols="30"><?php echo $ar; ?></textarea></td> </tr> <tr> <td>Software:</td> <td><input name="name" size="40" maxlength="255" value="<?php echo $name; ?>"> <td><input type="file" name="downl"> </td> </tr> <tr> <td colspan="3" class="submit"><input type="submit" name="submit" value="Add"></td> </tr> </table> </form> <?php } include "inc/footer.php"; ?>
  13. how do you write this type of code echo only in id[3] echo 'this'; if on different id do not echo for example if i am on myfile.php?id=3
  14. THANK YOU maybe i should buy PHP book and start learning thanks all again TC
  15. yeah i did realize it when u told me action="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?> but still got one error
  16. i just noticed that this was missing from the form enctype="multipart/form-data" now the problem is on 6 and on 27 the file is uploading to the dir now but the database is not getting the filename! any idea? Notice: Undefined index: id in /home/kufasoft/public_html/admin/image-edit.php on line 6 Notice: Undefined index: uploadedfile in /home/kufasoft/public_html/admin/image-edit.php on line 27 The file has been uploaded, and your information has been added to the directory
  17. ok i fixed the $_SERVER['PHP_SELF'] code :-X and removed elseif (id i got this error when uploading.. edit-image.php <?php include "inc/header.php"; error_reporting(E_ALL); $id = $_GET['id']; if(isset($_POST['submit'])) { //global variables $name = $_POST['name']; $pic=($_FILES['photo']['name']); $result = mysql_query("UPDATE changeimage SET name='$name', photo='$pic' WHERE id='$id' ",$connect); //This is the directory where images will be saved $target = "uploads/"; $target = $target . basename( $_FILES['photo']['name']); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } } $result = mysql_query("SELECT * FROM changeimage WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { $name = $row["name"]; $pic = $row["photo"]; ?> <br> <h3>::Edit News</h3> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <input type="hidden" name="id" value="<?php echo $row['id']?>"> <table border="0" cellspacing="4" cellpadding="4"> <tr> <td>Select Category:</td> </tr> <tr> <td>Title:</td> <td><input name="name" size="40" maxlength="255" value="<?php echo $name; ?>"></td> </tr> <tr> <td>Content:</td> <td>Photo: <input type="file" name="photo"><br> </td> </tr> <tr> <td colspan="3" class="submit"><input type="submit" name="submit" value="Submit"></td> </tr> </table> <?php } //end of while loop include "inc/footer.php"; ?>
  18. i got this wierd error when i added your code and trust me i have been trying to fix it for 2 days now :/
  19. not really what i want as i already have done this... im trying to make an edit page for the uploaded file i have done a database with id, name, filename, but the thing is i cant get it to upload on the edit page... but on the adding page it is working just fine it is sendig data to the database and uploading as it should
  20. no error... the upload is just not working the codes are probably wrong!!
  21. im trying to make an edit page for my uploaded files the problem is i cant make it to work on uploading the file if anyone of you who can just have look on my codes and see where the problem is it would be great <?php include "inc/header.php"; $id = $_GET['id']; if(isset($_POST['submit'])) { //global variables $name = $_POST['name']; $pic = $_POST['photo']; $result = mysql_query("UPDATE changeimage SET name='$name', photo='$pic' WHERE id='$id' ",$connect); echo "<b>Your post have been added successfully"; //This is the directory where images will be saved $target = "uploads/"; $target = $target . basename( $_FILES['photo']['name']); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } } elseif($id) { $result = mysql_query("SELECT * FROM changeimage WHERE id='$id' ",$connect); while($row = mysql_fetch_assoc($result)) { $name = $row["name"]; $pic = $row["photo"]; ?> <br> <h3>::Edit News</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> <input type="hidden" name="id" value="<?php echo $row['id']?>"> <table border="0" cellspacing="4" cellpadding="4"> <tr> <td>Select Category:</td> </tr> <tr> <td>Title:</td> <td><input name="name" size="40" maxlength="255" value="<?php echo $name; ?>"></td> </tr> <tr> <td>Content:</td> <td>Photo: <input type="file" name="photo"><br> </td> </tr> <tr> <td colspan="3" class="submit"><input type="submit" name="submit" value="Submit"></td> </tr> </table> <?php } //end of while loop }//end else include "inc/footer.php"; ?>
  22. sorry about that i did not see your post it is working fine now ill remember for next time to specify the fields and having mysql_error thanks problem solved
×
×
  • 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.