-
Posts
498 -
Joined
-
Last visited
Never
Everything posted by jesushax
-
thanks all sorted now also tried uploading a 2mb image got thsi error again Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 8000 bytes) in /home/fhlinux153/c/cwservicesltd.co.uk/user/htdocs/admin/news/add_news.php on line 57 but the file is uploaded its jus teh thumbnail that isnt created and my upload limit is 4mb what could this mean? cheers
-
right i figured it out but dont know how to work change it the for each statment means do this code for every image, but that would mean that each textfield in the form would have to have a field for every file thats there meaning i need to execute the sql outside of the foreach statement so where in this script can i execute sql after the for each is finished cos i cant do a then {sql} after the for each can i, any ideas anyone? thanks
-
hi been working with yoru code to incorporate it with my news system, dont know what ive done to make it not work, can you point me in the right direction? THanks error: code: <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_head.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc'); $absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/";//Absolute path to where files are uploaded $thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/thumbs/"; //Absolute path to where thumbs are to be stored if you want this $size_limit = "yes"; //do you want a size limit yes or no. $limit_size = "4000000"; //How big do you want size limit to be in bytes $limit_ext = "yes"; //do you want to limit the extensions of files uploaded $ext_count = "4"; //total number of extensions in array below $extensions = array(".jpg", ".jpeg", ".png", ".gif"); //List extensions you want files uploaded to be function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){ // SET THE IMAGE COMPRESSION $g_imgcomp=100-$imgcomp; // CHECK TO SEE IF THE IMAGE EXISTS FIRST if(file_exists($sourcefile)){ // FIRST WE GET THE CURRENT IMAGE SIZE $g_is=getimagesize($sourcefile); /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/ // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){ // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE $new_width=$g_is[0]; $new_height=$g_is[1]; } else { // GET VALUE TO CALCULATE WIDTH AND HEIGHT $w_adjust = ($maxsize / $g_is[0]); $h_adjust = ($maxsize / $g_is[1]); // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT if($w_adjust <= $h_adjust){ // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER $new_width=($g_is[0]*$w_adjust); $new_height=($g_is[1]*$w_adjust); } else { // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER $new_width=($g_is[0]*$h_adjust); $new_height=($g_is[1]*$h_adjust); } } //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." ) $image_type = strrchr($sourcefile, "."); //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION switch($image_type) { case '.jpg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.jpeg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.png': $img_src = imagecreatefrompng($sourcefile); break; case '.gif': $img_src = imagecreatefromgif($sourcefile); break; default: echo("Error Invalid Image Type"); die; break; } // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT $img_dst=imagecreatetruecolor($new_width,$new_height); // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]); // OUTPUT THE IMAGE AS A JPEG. // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE. imagejpeg($img_dst, $destination, 100); // DESTROY THE NEW IMAGE imagedestroy($img_dst); return true; } else { return false; } } if(!isset($_POST['submit'])){ $extens = ''; if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) { $extens = "any extension"; } else { $ext_count2 = $ext_count+1; for($counter=0; $counter<$ext_count; $counter++) { $extens .= " $extensions[$counter]"; } } if (($limit_size == "") or ($size_limit != "yes")) { $limit_size = "any size"; } else { $limit_size .= " bytes"; $mb_size = ($limit_size/1000000); } $pichead = "<li><font size=\"2\" color=660000>File extension must be $extens<b>"; $pichead .="</b></font> <li><font size=\"2\" color=660000>Maximum file size is $limit_size ($mb_size MB)</font></li> <li><font size=\"2\" color=660000>No spaces in the filename</font></li>"; ?> <p><? echo $pichead; ?></p> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <p>Pictures:<br /> <?php $files = 2; // Change this line for the number of uploads you want to allow for($i=1; $i<=$files; $i++){ echo "Picture $i <input type=\"file\" name=\"pictures[]\" /><br />\n"; } ?> <h3>Add News</h3> <table width="100%"> <tr> <td style="width:80%;"><span style="width:20%;">News Title: </span></td> </tr> <tr> <td style="width:80%;"> <input type="text" size="45" name="txtNewsTitle" /></td> </tr> <tr> <td> </td> </tr> <tr> <td>News Brief :</td> </tr> <tr> <td><textarea name="txtNewsShort" cols="70" rows="12" id="txtNewsShort"></textarea></td> </tr> <tr> <td > </td> </tr> <tr> <td><strong>Attachments:</strong></td> </tr> <tr> <td>Attachment<input name="ufile[]" type="file" id="ufile[]" size="25" /> </td> </tr> <tr> <td> </td> </tr> <tr> <td >News Full :</td> </tr> <tr> <td ><textarea name="txtNewsFull" cols="70" rows="12" id="txtNewsFull"></textarea></td> </tr> <tr> <td > </td> </tr> <tr> <td style="height:32px;"><div style=" text-align:center"> <input type="submit" name=submit value="Add News" /> <input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/news/index.php'" /> </div></td> </tr> </table> </form> <?php } else { $i=0; //$photoarray = array(); foreach ($_FILES["pictures"]["error"] as $key => $error) { $file_name = $_FILES["pictures"]['name'][$i]; // can call this anything you like this will take the original name $file = $_FILES["pictures"]['tmp_name'][$i]; $file_size = $_FILES["pictures"]['size'][$i]; //$photoarray[$i+1]= $file_name; $endresult = "<font size=\"4\" color=990000>$file_name uploaded successfully</font>"; if ($file_name == "") { $pic = $i+1; $endresult = "<font size=\"4\" color=990000>Pic#$pic Not selected</font>"; }else{ if(file_exists("$absolute_path/$file_name")) { $endresult = "<font size=\"4\" color=990000>File Already Existed</font>"; } else { if (($size_limit == "yes") && ($limit_size < $file_size)) { $endresult = "<font size=\"4\" color=990000>File was to big</font>"; } else { $ext = strrchr($file_name,'.'); if (($limit_ext == "yes") && (!in_array($ext,$extensions))) { $endresult = "<font size=\"4\" color=990000>File is wrong type</font>"; }else{ // first move the file to move_uploaded_file($file, $absolute_path.$file_name); // Save full size image with max width/height resampleimage("800", $absolute_path.$file_name, $absolute_path.$file_name, 0); // Comment this line out if you don't want to resize the image change the "800" to the size you want // Save thumb image with max width/height of 200 resampleimage("125", $absolute_path.$file_name, $thumb_path.$file_name, 0); // Comment this line out if you don't want to create a thumbnail, change the 200 to the size you want } //mysql here $ext = strrchr($_FILES["pictures"]['name'][$i], "."); $n = $i+1; $file_name = "file".$n.$ext; $path1= $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/".$HTTP_POST_FILES['ufile']['name'][0]; copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); $NewsTitle = $_POST["txtNewsTitle"]; $NewsShort = $_POST["txtNewsShort"]; $NewsAttach = $HTTP_POST_FILES['ufile']['name'][0]; $NewsFull = $_POST["txtNewsFull"]; $NewsDate = date("d/m/y"); mysql_query("INSERT INTO tblNews(NewsTitle, NewsShort, NewsImage1, NewsAttachment, NewsFull, NewsImage2, NewsDateAdded, NewsArchive) Values ( '$NewsTitle', '$NewsShort', '$$file_name', '$NewsAttach', '$NewsFull', '$$file_name', '$NewsDate','0') ") or die(mysql_error()); header("Location: /admin/news/index.php"); } } } $i++; echo $endresult."<br>"; } } echo "</div>"; include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); ?>
-
thanks also got this error messsage when trying to upload a large file Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 8000 bytes) in /home/fhlinux153/c/cwservicesltd.co.uk/user/htdocs/upload.php on line 44 could you tell me what it means? and with regards to the pdf and word doc uploads, good idea bad idea? cheers
-
i didnt even post the code lol whoooops here it is <?php if(isset($_POST['submit'])) { /* Image Resizer / Thumbnailer Script Daniel Neri Viper Creations www.vipercreations.com */ //make sure this directory is writable! $path_thumbs = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/"; //the new width of the resized image, in pixels. $img_thumb_width = 125; // $extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed) //List of allowed extensions if extlimit = yes $limitedext = array(".gif",".jpg",".png",".jpeg",".bmp"); //the image -> variables $file_type = $_FILES['vImage']['type']; $file_name = $_FILES['vImage']['name']; $file_size = $_FILES['vImage']['size']; $file_tmp = $_FILES['vImage']['tmp_name']; //check if you have selected a file. if(!is_uploaded_file($file_tmp)){ echo "Error: Please select a file to upload!. <br>--<a href=\"$_SERVER[php_SELF]\">back</a>"; exit(); //exit the script and don't process the rest of it! } //check the file's extension $ext = strrchr($file_name,'.'); $ext = strtolower($ext); //uh-oh! the file extension is not allowed! if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { echo "Wrong file extension. <br>--<a href=\"$_SERVER[php_SELF]\">back</a>"; exit(); } //so, whats the file's extension? $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; //create a random file name $rand_name = md5(time()); $rand_name= rand(0,999999999); //the new width variable $ThumbWidth = $img_thumb_width; ////////////////////////// // CREATE THE THUMBNAIL // ////////////////////////// //keep image type if($file_size){ if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){ $new_img = imagecreatefromjpeg($file_tmp); }elseif($file_type == "image/x-png" || $file_type == "image/png"){ $new_img = imagecreatefrompng($file_tmp); }elseif($file_type == "image/gif"){ $new_img = imagecreatefromgif($file_tmp); } //list the width and height and keep the height ratio. list($width, $height) = getimagesize($file_tmp); //calculate the image ratio $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $ThumbWidth; $newheight = $ThumbWidth/$imgratio; }else{ $newheight = $ThumbWidth; $newwidth = $ThumbWidth*$imgratio; } //function for resize image. if (function_exists(imagecreatetruecolor)){ $resized_img = imagecreatetruecolor($newwidth,$newheight); }else{ die("Error: Please make sure you have GD library ver 2+"); } //the resizing is going on here! imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); //finally, save the image ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext"); ImageDestroy ($resized_img); ImageDestroy ($new_img); } //ok copy the finished file to the thumbnail directory move_uploaded_file ($file_tmp, "$path_big/$rand_name.$file_ext"); /* Don't want to copy it to a separate directory? Want to just display the image to the user? Follow the following steps: 2. Uncomment this code: /* /* UNCOMMENT THIS IF YOU WANT */ //echo "IMG:<img src=\"$path_big/$rand_name.$file_ext\" />"; //exit(); //*/ //and you should be set! //success message, redirect to main page. $msg = urlencode("$title was uploaded! <a href=\"upload.php\">Upload More?</a>"); header("Location: upload.php?msg=$msg"); exit(); }else{ //if there is a message, display it if(isset($_GET['msg'])) { //but decode it first! echo "<p>".urldecode($_GET['msg'])."</p>"; } //the upload form echo " <form action=\"$_SERVER[php_SELF]\" method=\"post\"enctype=\"multipart/form-data\">\n <p>File:<input type=\"file\" name=\"vImage\" /></p>\n <p><input type=\"submit\" name=\"submit\" value=\"Submit\" /></p>"; } ?> its good it works, but can i add multiples to it?
-
the while function loops through records yes? so if there is nothing to loop through what can i put, it doesnt like else this is what i mean this doesnt work...? while ($row = mysql_fetch_array($SQL)) { im loopign records here } else { echo "There are no current records."; }
-
bloody marvellous thanks friend also thast alot for the desctiptions helps alot! keeping that stored for future ref thankyou! :D
-
that code gave this... Array ( [0] => Array ( [0] => 5 [PortID] => 5 [1] => Vivergo Fuels [PortTitle] => Vivergo Fuels [2] => asdkjasdklj [PortSub] => asdkjasdklj [3] => Web [PortType] => Web [4] => VIV1.png [PortImage1] => VIV1.png [5] => VIV2.png [PortImage2] => VIV2.png [6] => VIV3.png [PortImage3] => VIV3.png [7] => asdas as das d asd [PortDetails] => asdas as das d asd [8] => 30/03/08 [PortDateAdded] => 30/03/08 ) [1] => Array ( [0] => 4 [PortID] => 4 [1] => Construction Works [PortTitle] => Construction Works [2] => asdfhjsdfajhsdfsdf [PortSub] => asdfhjsdfajhsdfsdf [3] => Web [PortType] => Web [4] => ConsW1.png [PortImage1] => ConsW1.png [5] => ConsW2.png [PortImage2] => ConsW2.png [6] => ConsW3.png [PortImage3] => ConsW3.png [7] => asdasd asd asd asd as das [PortDetails] => asdasd asd asd asd as das [8] => 29/03/08 [PortDateAdded] => 29/03/08 ) [2] => Array ( [0] => 3 [PortID] => 3 [1] => City Works [PortTitle] => City Works [2] => asldhasldhask [PortSub] => asldhasldhask [3] => Web [PortType] => Web [4] => CityW1.png [PortImage1] => CityW1.png [5] => CityW2.png [PortImage2] => CityW2.png [6] => CityW3.png [PortImage3] => CityW3.png [7] => sdasdasdasd asdas dasd asd asd [PortDetails] => sdasdasdasd asdas dasd asd asd [8] => 28/03/08 [PortDateAdded] => 28/03/08 ) [3] => Array ( [0] => 2 [PortID] => 2 [1] => Design Development Solutions Ltd [PortTitle] => Design Development Solutions Ltd [2] => asdasad [PortSub] => asdasad [3] => Web [PortType] => Web [4] => DDS1.png [PortImage1] => DDS1.png [5] => DDS2.png [PortImage2] => DDS2.png [6] => DDS3.png [PortImage3] => DDS3.png [7] => asdasdasdasdasdasdasd [PortDetails] => asdasdasdasdasdasdasd [8] => 27/03/08 [PortDateAdded] => 27/03/08 ) [4] => Array ( [0] => 1 [PortID] => 1 [1] => Fast Track Karting [PortTitle] => Fast Track Karting [2] => Hulls Prermier Karting Arena [PortSub] => Hulls Prermier Karting Arena [3] => Web [PortType] => Web [4] => FT1.png [PortImage1] => FT1.png [5] => FT2.png [PortImage2] => FT2.png [6] => FT3.png [PortImage3] => FT3.png [7] => design inasdasd asdasd asd as dasd asd [PortDetails] => design inasdasd asdasd asd as dasd asd [8] => 26/03/08 [PortDateAdded] => 26/03/08 ) )
-
ok thanks, i think of got it now but i still cant figure this out... what the below does it print each 'PortTitle' 3 times and move to the next row and do the same for all the other records i want the rows to increment after portitle has been displayed in a row 3 times so title 1 | title 2 | title 3 title 4 | title 5 | title 6 title 7 | title 8 | <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); $res = mysql_query("SELECT * FROM tblPortfolio WHERE PortType='Web' ORDER BY PortDateAdded DESC") or die(mysql_error()); $data=""; $data .="<table><tr>"."\n"; while($row=mysql_fetch_array($res)) { for ($i=1; $i<=3; $i++){ $data .="<td>". $row['PortTitle']."</td>"."\n"; } $data .="</tr><tr>"."\n"; } $data .="</tr></table>"."\n"; echo $data; ?>
-
hi im looking at this code and im trying to udnerstand it i know it prints hello world 5 times but and it goes (initialization, conidtion,increment) but i really need someone to dumb it down for me if they could i undersatnd the conidtion thats imple maths but the initilaiztion and the increment how do they work and sutff? Cheers <html> <body><?php for ($i=1; $i<=5; $i++) { echo "Hello World!<br />"; } ?></body> </html>
-
i see isee, gettign somewhere now but look the below im trying to get the PortTitle to display 3 times then move down to the next row and prtin it 3 more times but obviously the next record <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); $res = mysql_query("SELECT * FROM tblPortfolio WHERE PortType='Web' ORDER BY PortDateAdded DESC") or die(mysql_error()); $data=""; $data .="<tr><td><table><tr>"; while($row=mysql_fetch_array($res)) { $data .="<td>". $row['PortTitle']." </td>"; if($i%3 ==0) { $data .="</tr><tr>"; } } $data .="</table></td></tr>"; echo $data; ?>
-
bah im confused, cant work either of the above out, the second one gives numbers from 1-10 in teh right way but i dont know where to put my records and the first one doesnt count the records just puts them in a td.... im tryign to figure it out here, bt not so much luck lol
-
how do i do this?
-
hi could someone tell me how i can create a table and when the number of </td> = 3 or the number of records = 3 then write a <tr> to make them go on to the next row. Thanks