Jump to content
xisto Community

apple

Members
  • Content Count

    32
  • Joined

  • Last visited

Everything posted by apple

  1. I want to update mysql records with basic form by using OOP PHP. Im doing in following way but i want to do by a function, so that i dont. please anybody help me, how can that. Thanks everybody. <?if($_POST[submit]){ $title = $_POST['title']; $body = $_POST['body']; $result = mysql_query("UPDATE blog SET title='$title', body='$body' WHERE id='$postid' ") or die (mysql_error()); echo "<b>Thank you! News UPDATED Successfully!<br>"; } ?><?$result = mysql_query("SELECT * FROM blog WHERE id='$postid' ") or die (mysql_error()); while($myrow = mysql_fetch_assoc($result)) { $title = $myrow["title"]; $body = $myrow["body"]; ?><br><h3>::Edit News</h3><form method="post">Title: <input name="title" size="40" maxlength="255" value="<? echo $title; ?>"><br>Text1: <textarea name="body" rows="7" cols="30"><? echo $body; ?></textarea><br><input type="submit" name="submit" value="Submit"></form>
  2. Hello.. Im looking for some help. I want to use preg_replace function to replace the following type of code tags. <code lang="php"></code><code lang="javascript"></code><code lang="css"></code> My question is that, in the above code tags, language (lang) is not always same, how can i use preg_replace with the above code tags to place them with something. Any help will be very much appreciated. thanks.
  3. okay.. Below, the file fb4.php contains your solution 1 code and is located in directory "fb" . there are many sub directories, the following adress appears after clicking on a subdirectory name "images". LOCALHOST/test/fb/fb4.php?dir=images/ This page prints only this "Unable to open"... it can not open any subdirectory.
  4. Thank you once again for your detailed explanation.. i really appreciate it.. your first solution is very nice.. but when i click on any subdirectory.. i get the message "Unable to open".. why it is unable to open the subdirectory
  5. Thanks for your help.. but this code displays all the files of sub-folders on the index page.. i want to display the sub-folder files when clicked on the sub-folder.thanks.
  6. Hey I want to create a very simple file browser, so that, it reads all the sub-folders which are places in a directory, and the files inside the sub-folders (It reads only files inside sub-folders and list them in simply. ) Also, it creates a directory (any name) inside each sub folder. My Following code reads on the files inside the main directory, it does not read the files inside the sub-folders.. I appreciate any help. <?$path = "./";$dir_handle = @opendir($path) or die("Unable to open $path");while ($file = readdir($dir_handle)) {if($file == "." || $file == ".." || $file == "index.php" )continue;echo "<a href=\"$file\">$file</a><br />";}closedir($dir_handle);?>
  7. I am trying to do a simple thing. I want to display all the images of a directory on a single page with the checkbox next to each image, so that i can select multi images and i can delete selected images. Following few lines of code display the images of a directory.. i need help to put the check boxes with each image. and I dont understand how can i select multi images with check box and then delete them. I hope someone can help. thanks. <?php$path = "./";$dir_handle = @opendir($path) or die("Unable to open folder");while (false !== ($file = readdir($dir_handle))) {if($file == "index.php")continue;if($file == ".")continue;if($file == "..")continue;echo "<img src='$file' alt='$file'><br />";}closedir($dir_handle);?>
  8. There are many websites which offer free sms from website to mobile phone devices. I want to ask what is the technology behind that? Is it some SMS gateway? If someone want to create this service, is it free ? I want to know more about it, if someone can give me more information?Thanks
  9. yes i have windows vista ultimate edition.. what i want to do is, to have dynamic ip.. i have static ip all the time.. but i need dynamic. any help will be very appreciated. thanks
  10. Yes im on a network and i think its my lan ip.(i dont get internet connection directly from isp).. can you please tell more details about it.. how can i do that? thanks
  11. I have static ip. I want to convert it into dynamic ip. please let me know if its possible to do with the help of any software?thanks
  12. Can someone please have a look at the following code, this uploads an image, and make it in 2 sizes, one size is max. 600 x 800, uploads to images folder and second 120 x 120 and uploads to thumbs folder.this script works fine, with normal size images, but if i try to upload large pics( for example, an image with dimension 2432 x 3300, it shows blank page, and uploads the original image without sizing to "image" folder, and doesnt make any small thumbnail... I hope u understand.. Please someone help me, i shall be so thankful. <?PHPsession_start(); header("Cache-control: private");function Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path) { $s_path = trim($s_path); $o_path = trim($o_path); $save = $s_path . $save; $file = $o_path . $file; $ext = strtolower(end(explode('.',$save))); list($width, $height) = getimagesize($file); if(($width>$t_w) OR ($height>$t_h)) { $r1 = $t_w/$width; $r2 = $t_h/$height; if($r1<$r2) { $size = $t_w/$width; }else{ $size = $t_h/$height; } }else{ $size=1; } $modwidth = $width * $size; $modheight = $height * $size; $tn = imagecreatetruecolor($modwidth, $modheight); switch ($ext) { case 'jpg': case 'jpeg': $image = @imagecreatefromjpeg($file) or die ("Seems to be problem"); break; case 'gif': $image = imagecreatefromgif($file); break; case 'png': $image = imagecreatefrompng($file); break; } imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) or die("he"); imagejpeg($tn, $save, 100) or die ("heheh");; return;}function write_beg($filename, $data){ $handle = fopen ($filename, "r"); $old_content = fread ($handle, filesize ($filename)); fclose ($handle); $final_content = $data.$old_content; $handle2 = fopen ($filename, "w"); $finalwrite = fwrite ($handle2, $final_content); fclose ($handle2);} # check to see if form submitted# if yes, process form variables# if no, display formif($_POST["action"]== "Upload Image"){ # define the constant variables $uploadDir = 'images/'; // main picture folder $max_height = 600; // largest height you allowed; 0 means any $max_width = 800; // largest width you allowed; 0 means any $max_file = 2000000; // set the max file size in bytes $image_overwrite = 1; // 0 means overwite; 1 means new name $allowed_type01 = array( "image/gif", "image/pjpeg", "image/jpeg", "image/png", "image/x-png", "image/jpg"); // add or delete allowed image types $do_thumb = 1; // 1 make thumbnails; 0 means do NOT make $thumbDir = "thumbs/"; // thumbnail folder $thumb_prefix = ""; // prefix for thumbnails $thumb_width = 120; // max thumb width $thumb_height = 120; // max thumb height $flat_file = 1; // 1 flat file for data; 0 database $what_error = array(); # get basic info about uploaded file $original_name = $_FILES['imagename']['name']; $original_tmp = $_FILES['imagename']['tmp_name']; $original_size = $_FILES['imagename']['size']; $original_type = $_FILES['imagename']['type']; # do some basic error trapping and cleanup if($original_size>$max_file) { //too large, go back to form array_push($what_error, "File Size Exceeds Limit"); } if( $original_size<1) { //no file was uploaded array_push($what_error, "Please Select A File To Upload"); } if(!in_array($original_type, $allowed_type01)) { // wrong file type array_push($what_error, "File Type Is Not Allowed"); } if(count($what_error)>0) { // send to error page $_SESSION["resultset"] = $what_error; echo $what_error; //echo '<meta http-equiv="refresh" content="0;URL=mpg_error.php"> '; exit(); } # check to see if file already exists in the folder # if it exists AND rename option is , create new name $does_it = FALSE; $original_name = strtolower($original_name); if(file_exists($uploadDir . $original_name)) { if($image_overwrite == 1) { //rename while(!$does_it) { $add_this_name = rand(1,200); $original_name = $add_this_name . $original_name; if(!file_exists($uploadDir . $original_name)) { $does_it = TRUE; } } } } # attempt to MOVE the image to its proper location $uploadFile = $uploadDir . $original_name; if (move_uploaded_file($_FILES['imagename']['tmp_name'], $uploadFile) ) { // continue } else { // send to error page array_push($what_error, "error - unknown cause"); $_SESSION["resultset"] = $what_error; echo "error - unknown cause"; //echo '<meta http-equiv="refresh" content="0;URL=mpg_error.php"> '; exit(); } # check to see if image needs resizing and act accordingly list($original_width, $original_height) = getimagesize($uploadDir . $original_name);//echo $original_height; if($max_height<$original_height OR $max_width<$original_width) { // dimensions are too large - resize Resize_Image($original_name,$original_name,$max_width,$max_height,$uploadDir,$uploadDir); echo "image resized done<br>"; } # check to see if make thumbnails is true # if yes make and store thumb $thumb_name = $thumb_prefix . $original_name; if($do_thumb == 1) { // make a thumb Resize_Image($thumb_name,$original_name,$thumb_width,$thumb_height,$thumbDir,$uploadDir); echo "thumb too"; }}else{?><html><head><title>My Photo Gallery Upload Form</title><link rel="stylesheet" type="text/css" href="shared_files/textsize.css"></head><body bgcolor="#ffffff" text="#0000a6" link="#0000a6" vlink="#0000a6" alink="#0000a6"><div style="position: absolute; top: 50px; left: 300px; width:90%; font-size:10pt; padding:10px;filter:shadow(color:gray);"><div style="HEIGHT:250px; border : solid 2px #0000a0; padding : 4px; WIDTH:380px; OVERFLOW:auto; background-color:#fcfcfc; layer-background-color:#fcfcfc; visibility: visible; "><form action="<?php echo $PHP_SELF ?>" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000">Browse a File to Upload: <br> <input type="file" name="imagename"><br>Enter a title for the picture<br><input type="text" name="imagetitle" size="40" maxlength="80" value=""><br>Enter your name<br><input type="text" name="artistname" size="40" maxlength="80" value=""><br>Enter a description for the picture<br><input type="text" name="imagedescript" size="40" maxlength="250" value=""><br><input type="submit" value="Upload Image" name="action"><br><br>note: <font color="#ff0080">max file size is: 2megs</font></div></div></body></html><?PHP}?> Notice from truefusion: Placed code into codebox.
  13. suppose i make a dropdown menu having value 1, 2, 3, 4, 5, one option can be selected, and selected option is stored in database. now i create an edit page, how do i display the selected value in the menu and other values in dropdown, for example, Menu is like Select One 1 2 3 4 5 and i select 3, this 3 is stored in database, now on the edit page i want to show 3 as already selected, something like that.. [quote]<select name="select_thing"> <option value="1">1</option> <option value="2">2</option> <option value="3" selected>3</option> <option value="4">4</option> <option value="5">5</option></select>[/quote]I will be very thankful, if someone could help by explaining how do i make option 3 as selected.. eg. how i know option 3 is selected and stored in db.
  14. I want to create a simple dropdown menu, which gets data from mysql.. but i need some help... that, for example, my dropdown menu looks like-- Select --Option1Option2Option 3im not getting the right syntax to get the selected option and then do something with that selected option..e..g if i select option1, i want to print.. "option 1 selected" etc. can someone help me with this pls.
  15. While dealing with such a links in php page.php?id=1i dont want that someone access this page directly using page.php.. i can give some custom message incase someone try to access page like: page.php okay i can make it by using if condition etc.. but the other problem is that, if someone try to access like, page.php?id= in this case (where id is not given, but there's only "?id= " which makes no sense.. in that case i want to make some custom msg etc. how i can handle this situation? Regards
  16. Can someone tell me any software to record the live video which is on computer screen.. for example i can see a tv channel on my computer.. i want to record something from it.. which software does thatthanks
  17. Can someone give me idea what is term 'permalink' in blogs using php.. and for example if i have a post like, myblog.php?post_id=xxx&cat_id=zzz how i can make like permalink of this post ??
  18. suppose i have a page, page.php?part=1 there i have some text fields. user will give input, but after taking input, it will not put the data in mysql .. but it will take to the next step.. page.php?part=2 (if any field is left blank, it will not go to next page.. ) . and there also some fields.. after the user has filled that form also, then it will insert all data (from part1 and part 2) in mysql. i want to ask, how i can collect data from 2 pages and put in mysql at once.
  19. Oh yes, that was what i was looking for.. thank you both of you guys
  20. I want to make a simple page in php. it has 3 steps.. like ,page.php there i say, lets go to second step.. and i want to create page.php?step=2 and there.. i say lets go to step3 and i create page.php?step=3How i can create like that.. anyhelp please
  21. I make a signup page. I want that when someone signups and login for first time..then he is directed to the page X automatically. but after that it is redirected to Page Y always... Its pretty simple thing to do but im not understanding how i can make the script to identify that a person has logged in for first time ... anyhelp would be so welcome.Thanks.
  22. Can somebody help me in creating a very simple javascript.. for example, the following code is example to delete a row from mysql.. all i want to do is.. that, when i click on delete, it gives a popup window , asking me if i really want to delete the row.. if i say Yes then it takes the action.. but if i say no then it takes back.' $result = mysql_query("select * from comments order by id desc limit 10");//the while loopwhile($r=mysql_fetch_array($result)){//getting each variable from the table$id = $r["id"];$self = $_SERVER['PHP_SELF'];echo $r["comment"];echo "<br />";echo "<a href = \"$self?id=$id\">delete</a>";}if(isset $_GET['id'])){$id = $_GET['id'];// --------- here code to connect to mysql and select database -----------$query= mysql_query("delete FROM comment where id =$id")or die(mysql_error());}
  23. Im using the following code, for very simple work.. it simply gets and print the comments which are stored in the database. Now it will show like comment 1. comment 2. comment 3. etc etc i want to add 'delete' option that i can delete any comment. it displays like comment 1. Delete comment 2. Delete comment 3. Delete So that when i click on delete, it simply deletes the comment and print the remaining comments. Its very simple. i hope you understand.
  24. Many of you would have noticed that on flickr, there's feature that you can select some part of the picture (usually there' a small box) and add description for that part when you upload. Can someone tell me what kind of feature it is, and how it can be made ? im very keen to learn about that. I have attached the image below, there' you can see the boxes on the picture.. i want to learn how to make that feature.. please help me. Thanks. Sami.
  25. here's the code. <?ob_start();include("config.php");if (!$_GET[nick]){$getuser = mysql_query("SELECT * from users order by id asc");while ($user = mysql_fetch_array($getuser)){echo ("<a href=\"album1.php?nick=$user[username]\">$user[username]</a><br />\n");}}ELSE{$getuser = mysql_query("SELECT * from pictures where username = '$_GET[nick]'");$usernum = mysql_num_rows($getuser);if ($usernum == 0){echo ("User Not Found");}else{while ($row = mysql_fetch_array($getuser)) {echo "<a href='funnypics/$row[link]' target='_blank'><img src=funnypics/$row[link] width='200px'></a><br>";}}}?>
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.