Jump to content

gdfhghjdfghgfhf

Members
  • Posts

    218
  • Joined

  • Last visited

Everything posted by gdfhghjdfghgfhf

  1. hello, just one simple question i have a variable that contains stuff like this: $var = "cat - dog - fish" i'd like to keep only the part between the first " - " the result i'd want from the example above would be just "cat" thanks!
  2. i use $vbphrase because i am putting this script inside a vbulletin template... so all $vbphrase variables will be replaced with its corresponding language signification from the vbulletin's language and phrases system.... so basically it's just words and text, but i use it to have both a french and an english version of my site oui mon site est en francais Tu parles francais? D'ou viens tu?
  3. could you just fix the code for me... i'd understand better cuz right now i'm really lost..
  4. ehhh i don't understand i should remove all mysql_fetch_array parts?
  5. yeah well i'm stuck here... i know my problem is stupid but i'm still a newbie >< $query78 = "SELECT * from pp_files WHERE category = '$id'"; $res78 = mysql_query($query78) or die(mysql_error()); while($row = mysql_fetch_array($res78)) { $picture = $row["picture"]; $vidid = $row["id"]; $rows = mysql_num_rows($res78); } if ($rows > 0) { echo "<br><table width=\"85%\" align=\"center\" cellpadding=\"8\"><tr><td style=\"background: url(1.png); border: 1px dashed #FFFFFF; cellpadding: 5px;\" colspan=\"5\">"; echo "<center><b><font size=\"3\">$vbphrase[ilya]il y a <font size=\"5\">$rows</font> $vbphrase[vids]</font></b><br>"; $query78 = "SELECT * from pp_files WHERE category = '$id'"; $res78 = mysql_query($query78) or die(mysql_error()); while($row = mysql_fetch_array($res78)) { echo "<a href=\"videos/video.php?id=$vidid\"><img src=\""; echo $picture; echo "\" border=\"0\" alt=\"$vbphrase[vids_click]\"></a> "; } echo "<br><font size=\"2\"><a href=\"videos/submit.php\">$vbphrase[vids_add]</a></font></center></td></tr></table>"; } i have multiple items in tables of my database and i am trying to display all of the pictures, with a link to the corresponding picture my problem is that only the last item is displayed.... If there is 3 entry to display, 3 items will be displayed, but with the same picture (none) and the same link (last id of the array)
  6. but this wouldnt explain why i have no problem with my thumbs the script creates 2 images: the file itself, and a resized image (thumb) if it would be a problem of permissions, isn't both images supposed to have the same problem?
  7. oh yeah, and the script adds the description to the database after echo'ing it
  8. if i use mysql_real_escape , then my line breaks will be messed up if i use stripslashes, the /n will become just "n" so it's still messed up if i use no protection at all, then i will be vulnerable to sql injections?
  9. add ORDER BY id ASC (or DESC) to the end of the query.
  10. hello, i am trying to modify a script i downloaded. Basically it is a script to get informations from a youtube video. You enter the url, then it gets the name of the video and the description here is the function to get the description as you can see the author is using addslashes (i suppose its to prevent injections) well the problem is that the description is displayed wrongfully... foreign characters appears weird, and there is a slash before each single quote I tryed using mysql_real_escape_string instead, but then the line break wouldnt display correctly. How can i get a normal description, in a safe way to not get my ass hacked?
  11. Hello, i have a php script to upload image files. Once the image is sent, the script will upload it to a folder on my server... So far everything is good. If i install it on my old server (with php4) everything is working fine - i just have to upload the script and create the folder, not even touching the chmod's and letting the default settings. I can also access the image on my FTP and everything is good. My problem is that i use it on a newer server, with php5. I understand nothing of this weird error.. The script is installed the same way than on the old server... I will be able to upload the image, but my problem is when i connect to my FTP, my image is here, but i can't do anything with it. Here is the FTP error i am getting when i try to upload any images with the script: I can rename the file, but i can't change the rights, and i can't transfer it from my ftp (but i can view the image in my browser) Note that the script is uploading the big image, and it is also making a thumbnail file. I have no problem with the thumb, i can change the rights, open it, transfer it on my ftp, etc.... The only problem is around the BIG image.... Here is the code of the PHP script for uploading images: <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> $headinclude <title>$vboptions[bbtitle]</title> </head> <body> <?php include("db.php"); $bbuserinfo['userid'] = "1"; //This is the resize/sampler. function resample($img, $max_w, $max_h, $type, $thumb) { switch ($type) { case 2: // get original images width and height list($or_w, $or_h, $or_t) = getimagesize($img); // obtain the image's ratio $ratio = ($or_h / $or_w); // original image $or_image = imagecreatefromjpeg($img); // resize image? if ($or_w > $max_w || $or_h > $max_h) { // resize by height, then width (height dominant) if ($max_h < $max_w) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // resize by width, then height (width dominant) if ($max_w < $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } //Resize by neither (as it is equal anyways) if ($max_w == $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // copy old image to new image $rs_image = @imagecreatetruecolor($rs_w, $rs_h); @imagecopyresampled($rs_image, $or_image, 0, 0, 0, 0, $rs_w, $rs_h, $or_w, $or_h); } // image requires no resizing else { $rs_w = $or_w; $rs_h = $or_h; $rs_image = $or_image; } if($thumb == true) { $image = explode('/',$img); $x = 0; $num_dir = count($image)-1; while($x < count($image)-1) { $pre_img .=$image[$x]."/"; $x++; } $img = $pre_img."/sml_".$image[count($image)-1]; $img; } // generate resized image imagejpeg($rs_image, $img, 100); return true; break; case 3: // get original images width and height list($or_w, $or_h, $or_t) = getimagesize($img); // obtain the image's ratio $ratio = ($or_h / $or_w); // original image $or_image = imagecreatefrompng($img); // resize image? if ($or_w > $max_w || $or_h > $max_h) { // resize by height, then width (height dominant) if ($max_h < $max_w) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // resize by width, then height (width dominant) if ($max_w < $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } //Resize by neither (as it is equal anyways) if ($max_w == $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // copy old image to new image $rs_image = imagecreatetruecolor($rs_w, $rs_h); imagecopyresampled($rs_image, $or_image, 0, 0, 0, 0, $rs_w, $rs_h, $or_w, $or_h); } // image requires no resizing else { $rs_w = $or_w; $rs_h = $or_h; $rs_image = $or_image; } if($thumb == true) { $image = explode('/',$img); $img = $image[(count($image)-1)]."sml_".$image[count($image)]; print $img; } // generate resized image imagepng($rs_image, $img, 100); return true; break; case 4: // get original images width and height list($or_w, $or_h, $or_t) = getimagesize($img); // obtain the image's ratio $ratio = ($or_h / $or_w); // original image $or_image = imagecreatefromgif($img); // resize image? if ($or_w > $max_w || $or_h > $max_h) { // resize by height, then width (height dominant) if ($max_h < $max_w) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // resize by width, then height (width dominant) if ($max_w < $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } //Resize by neither (as it is equal anyways) if ($max_w == $max_h) { if ($or_h < $or_w) { $rs_w = $max_w; $rs_h = $rs_w * $ratio; } else { $rs_h = $max_h; $rs_w = $rs_h / $ratio; } } // copy old image to new image $rs_image = imagecreatetruecolor($rs_w, $rs_h); imagecopyresampled($rs_image, $or_image, 0, 0, 0, 0, $rs_w, $rs_h, $or_w, $or_h); } // image requires no resizing else { $rs_w = $or_w; $rs_h = $or_h; $rs_image = $or_image; } // generate resized image if($thumb == true) { $image = explode('/',$img); $img = $image[(count($image)-1)]."sml_".$image[count($image)]; print $img; } imagegif($rs_image, $img, 100); return true; break; } } ?> <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> <?php $headinclude;?> <title><?php $vboptions['bbtitle'];?></title> </head> <body> <br /><br /><br /><br /> <center> <?php $bbuserinfo['userid'] = "1"; if($bbuserinfo['userid'] != NULL) {} else { $url = 'connexion.php'; $timeout = 0; header('Refresh: ' . $timeout . ';url=' . $url); print' <meta http-equiv="refresh" content="'.$timeout.';url='.$url.';"> <script type="text/javascript"> setTimeout(function(){window.location.replace("'.$url.'; ", '.($timeout * 0).'); </script>'; } if($bbuserinfo['userid']) { print' <form action="'.$_server['php-self'].'" method="post" enctype="multipart/form-data" id="something" class="uniForm"> '; // @include("imgbands.php"); // print' <br /><hr /> <table> <tr> <td> Uploader la photo (#1): </td> <td> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> </td> </tr> <tr> <td> Description (optionel): </td> <td> <INPUT TYPE="TEXT" NAME="infos" VALUE="" size="60"> </td> </tr> </table> <INPUT TYPE="hidden" NAME="user" VALUE="'.$bbuserinfo['username'].'" size="60"> <input name="submit" type="submit" class="submitButton" value="AJOUTER L\'IMAGE" /> </form> '; } $band = $_POST['band']; if($_POST['submit']) { $imagenamz = $_FILES['new_image']['name']; $originalname = $_FILES['new_image']['name']; $date = date('dmy'); $imagename = "$band" . "_" . $date . "_" . $originalname; echo $imagename; $vraidate = date('d/m/y'); $nom = $_POST['user']; $infos = $_POST['infos']; echo "<br />L'image a été ajouté dans l'album photos de <b>$band</b><hr><br />"; $source = $_FILES['new_image']['tmp_name']; $target = "db/img/images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "db/img/images/" . $imagepath; //This is the new fileyou saving $file = "db/img/images/" . $imagepath; //This is the originalfile list($width, $height, $att) = getimagesize($file) ; $size = getimagesize($file); $uploadx = $size[0]; $uploady = $size[1]; } list($width, $height, $type, $attr) = getimagesize($target); resample($target, 800, 800, $type, false); resample($target, 150, 150, $type, true); if(isset($_POST['submit'])){ // if file exists // add to database $filename = 'db/img/images/sml_".$imagepath."'; if (file_exists($filename)) { $band = $_POST['band']; $originalname = $_FILES['new_image']['name']; $date = date('dmy'); $imagename = "$band" . "_" . $date . "_" . $originalname; // echo $imagename; $vraidate = date('d/m/y'); $nom = $_POST['user']; $infos = $_POST['infos']; $result = mysql_query("INSERT INTO bands_pics (id,band,url,date,infos,valide,user) VALUES ('NULL', '$band', '$imagename','$vraidate','$infos','0','$nom')"); } } ?> Someone help me plz! I'm desperate!
  12. i want to select all the entrys from item #7 to item #13 in a table... how can i do this? i tryed with $query = "SELECT * from bands_pics WHERE bandid = '$id' ORDER BY id DESC LIMIT 7, 13"; but it displays 13 entries and not #7 to #13
  13. Hello, i have a table in my database with a ID field... the ID is auto-incremented by 1 i already have a query which will display entry with (i.e.) id number 500 what i want to do is add a second query that will display the entry right after #500 i thought about just adding "WHERE id = id + 1" to the query, but some entries have been deleted, so the query could not work... how could i do this?
  14. i always get "1" as result ... am i supposed to replace $array by $cres or something?
  15. $cres = mysql_query($cquery) or die(mysql_error()); while($row = mysql_fetch_array($cres)) { $cfields = $row["customfields"]; echo $cfields; } this code will return a list like this cat dog horse cat cat fish I want to count the number of DIFFERENT items, in this array (in example it would be 4 different items) mysql_num_rows would return 6
  16. Hello, i am using mysql_fetch_array to display a basic query then i echo each one of the entry found i would like to count how many DIFFERENT entries are found with mysql_num_rows it will just count the total entries found
  17. i have a sql query that output some stuff from the database one of the entry contains a single quote (i.e.: Thumb's Up) it is breaking my sql query and messing up the page here is the query $filter = mysql_real_escape_string($title); $query = "SELECT * FROM quebec_thread WHERE title LIKE '%$filter%' AND forumid='18'"; ($title is a $_GET value) i tryed with mysql_real_escape_string() and addslashes() but i still get the same error... the entry in the database doesn't contain slashes 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 's Up%' AND forumid='18'' at line 1
  18. Ok here is the correct code: <?php /** * This funtion will take a pattern and a folder as the argument and go thru it(recursivly if needed)and return the list of * all files in that folder. * Link : http://www.bin-co.com/php/scripts/filesystem/ls/ * Arguments : $pattern - The pattern to look out for [OPTIONAL] * $folder - The path of the directory of which's directory list you want [OPTIONAL] * $recursivly - The funtion will traverse the folder tree recursivly if this is true. Defaults to false. [OPTIONAL] * $options - An array of values 'return_files' or 'return_folders' or both * Returns : A flat list with the path of all the files(no folders) that matches the condition given. */ function ls($pattern="*", $folder="", $recursivly=false, $options=array('return_files','return_folders')) { $current_folder = getcwd(); if($folder) { $folder = preg_replace('#([\\/]){2,}#', '$1', $folder); if(in_array('quiet', $options)) { // If quiet is on, we will suppress the 'no such folder' error if(!file_exists($folder)) return array(); } if(!chdir($folder)) return array(); } $get_files = in_array('return_files', $options); $get_folders= in_array('return_folders', $options); $both = array(); // Get the all files and folders in the given directory. if($get_files) $both = glob($pattern, GLOB_BRACE + GLOB_MARK); if($recursivly or $get_folders) $folders = glob("*", GLOB_ONLYDIR + GLOB_MARK); //If a pattern is specified, make sure even the folders match that pattern. $matching_folders = array(); if($pattern !== '*') $matching_folders = glob($pattern, GLOB_ONLYDIR + GLOB_MARK); chdir($current_folder); // Necessary incase of relative filepaths //Get just the files by removing the folders from the list of all files. $all = array_values(array_diff($both,$folders)); if($recursivly or $get_folders) { foreach ($folders as $this_folder) { if($get_folders) { //If a pattern is specified, make sure even the folders match that pattern. if($pattern !== '*') { if(in_array($this_folder, $matching_folders)) array_push($all, $this_folder); } else array_push($all, $this_folder); } if($recursivly) { // Continue calling this function for all the folders $new_folder = "$folder/$this_folder"; if(!$folder) $new_folder = $this_folder; $deep_items = ls($pattern, $new_folder, $recursivly, $options); # :RECURSION: foreach ($deep_items as $item) { array_push($all, $this_folder . $item); } } } } return $all; } $opt[0]="return_files"; $origine = $_GET['origine']; $tracks=ls ("*.{gif,jpg}","images/$origine",true,$opt); // print_r($tracks); // echo "<br><br><br><br>"; foreach ($tracks as $option) { $id = $_GET['id']; include("db.php"); $query = "SELECT title from news2 WHERE id='$id'"; $res = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res)) { $band = $row["title"]; } $id = $_GET['id']; rename("/home/qcanarco/public_html/db/img/images/$origine/$option", "/home/qcanarco/public_html/db/img/images/$origine/id".$id."_".$band."_$option"); echo $option; echo " renommé."; echo "<br>"; } $ki = $_GET['ki']; $vraidate = date('d/m/y'); $imagename = "id".$id."_".$band."_$option"; // $result=MYSQL_QUERY("INSERT INTO bands_pics (id,bandid,url,date,infos,valide,user)". // "VALUES ('NULL', '123', '123', '123','123','123','123')"); include("db.php"); $result=MYSQL_QUERY("INSERT INTO bands_pics (id,bandid,url,date,infos,valide,user)". "VALUES ('NULL', '$id', '$imagename', '$vraidate','$option','1','$ki')"); ?> Like i said, everything is working except it only adds the last item of the array instead of the whole array (1 row in db per array item)
  19. Ok here is a little script i use to rename multiple images files and store their names inside database It will look for all files in a folder, and output the list then it will rename each files ...so far everything is good... but then i want to add each of my files inside database my problem is that only the last item of the array will be added.... <?php /** * This funtion will take a pattern and a folder as the argument and go thru it(recursivly if needed)and return the list of * all files in that folder. * Link : http://www.bin-co.com/php/scripts/filesystem/ls/ * Arguments : $pattern - The pattern to look out for [OPTIONAL] * $folder - The path of the directory of which's directory list you want [OPTIONAL] * $recursivly - The funtion will traverse the folder tree recursivly if this is true. Defaults to false. [OPTIONAL] * $options - An array of values 'return_files' or 'return_folders' or both * Returns : A flat list with the path of all the files(no folders) that matches the condition given. */ function ls($pattern="*", $folder="", $recursivly=false, $options=array('return_files','return_folders')) { $current_folder = getcwd(); if($folder) { $folder = preg_replace('#([\\/]){2,}#', '$1', $folder); if(in_array('quiet', $options)) { // If quiet is on, we will suppress the 'no such folder' error if(!file_exists($folder)) return array(); } if(!chdir($folder)) return array(); } $get_files = in_array('return_files', $options); $get_folders= in_array('return_folders', $options); $both = array(); // Get the all files and folders in the given directory. if($get_files) $both = glob($pattern, GLOB_BRACE + GLOB_MARK); if($recursivly or $get_folders) $folders = glob("*", GLOB_ONLYDIR + GLOB_MARK); //If a pattern is specified, make sure even the folders match that pattern. $matching_folders = array(); if($pattern !== '*') $matching_folders = glob($pattern, GLOB_ONLYDIR + GLOB_MARK); chdir($current_folder); // Necessary incase of relative filepaths //Get just the files by removing the folders from the list of all files. $all = array_values(array_diff($both,$folders)); if($recursivly or $get_folders) { foreach ($folders as $this_folder) { if($get_folders) { //If a pattern is specified, make sure even the folders match that pattern. if($pattern !== '*') { if(in_array($this_folder, $matching_folders)) array_push($all, $this_folder); } else array_push($all, $this_folder); } if($recursivly) { // Continue calling this function for all the folders $new_folder = "$folder/$this_folder"; if(!$folder) $new_folder = $this_folder; $deep_items = ls($pattern, $new_folder, $recursivly, $options); # :RECURSION: foreach ($deep_items as $item) { array_push($all, $this_folder . $item); } } } } return $all; } // -------------------------------------------------------------------------------------- $opt[0]="return_files"; $origine = $_GET['origine']; $tracks=ls ("*.{gif,jpg}","images/$origine",true,$opt); // print_r($tracks); // echo "<br><br><br><br>"; foreach ($tracks as $option) { $id = $_GET['id']; include("db.php"); $query = "SELECT title from news2 WHERE id='$id'"; $res = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res)) { $band = $row["title"]; } $id = $_GET['id']; rename("/home/qcanarco/public_html/db/img/images/$origine/$option", "/home/qcanarco/public_html/db/img/images/$origine/id".$id."_".$band."_$option"); echo $option; echo " renommé."; echo "<br>"; $ki = $_GET['ki']; $vraidate = date('d/m/y'); $imagename = "id".$id."_".$band."_$option"; include("db.php"); $result=MYSQL_QUERY("INSERT INTO bands_pics (id,bandid,url,date,infos,valide,user)". "VALUES ('NULL', '$id', '$imagename', '$vraidate','$option','1','$ki')"); ) ?> could anyone help me debug my script? thanks edit: nvm, now the result is just totally blank.... my script is really messed up
  20. my script is already fine... and now i know what function to use for gifs, it's probably just an error with my the way i use it or something.... could anyone please just help me with that? i don't want to start over with another script
×
×
  • 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.