Jump to content

kev wood

Members
  • Posts

    456
  • Joined

  • Last visited

    Never

About kev wood

  • Birthday 04/19/1983

Contact Methods

  • MSN
    kevin-wood@hotmail.co.uk

Profile Information

  • Gender
    Male
  • Location
    Liverpool, England

kev wood's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. sorted. the code on the last post works i have no more silly symbols on the page
  2. thanks for the reply i understood that one better. from my reading htmlspecialchars() does basically the same htmlentities() but quicker. this bit i know but what i am stuck on is where i should be using it. i know i have state that the variable $cOption has htmlspaecialchars init and to get them to display i thought i would have to write it like this but it does not seem to be working for me $cOption = htmlspecialchars($_GET['o']);
  3. i will attempt to explain myself better. i have a web page which is using ajax to display the content of the pages within a div tag. the code is all working fine the content for each of the individual links are displaying in the div tag but if the text being sent to the html page contains semicolons, commers, inverted commers etc they display as symbols. the content is being taken from a php page which uses a case statement to select which section of the information is needed to be displayed. the code from the php page can be seen above. the links on the html page look as follows
  4. oni-kun?????? i dont undertand your post
  5. i have set up a ajax page to load the content froma php page on to my html pages. it works fine but it will not show the semicolons properly i am getting symbols instead. i have had this working correctly before but i have lost the code that was working and now i am stuck. i am pretty sure i sorted it by adding and stripping the slashes but i am not 100% on this. here is a copy of the php page which holds all the information <?php $cOption = $_GET['o']; switch($cOption) { case 1: echo "<h1>who we are</h1><br /> Welcome to our site here at design-flow Liverpool. We are a web design company that pride ourselves in producing functional and user friendly websites. We take great care in making sure that the websites we produce fit the needs of the client and the people who will be using the website on a regular basis. When we take on a website, we not only take on the responsibility to produce a website that is functional but we also feel it is our duty to try and understand the wishes of the client. In order for this to take place the client’s role in the site’s development is integral: from start to finish we will involve the client.<p> To do this, we must first build a good understanding of our client’s needs and wishes for the site. The way to facilitate this is by meeting with the client face to face to nurture a good relationship."; break; case 2: echo "<h1>why choose us</h1><br /> The reason to choose design-flow to build your company’s website is quite simple. All sites we build encompass the client’s passion for their company and here at design-flow we involve the client as much as possible. We believe for the website to truly reflect the wishes of the client, they must be involved in every step of the way from the initial design to the end product.<p> It is easy to build a site with no involvement from clients but the end product may not always be as pleasing to the client as it is to the designer. Every step of the way the client’s thoughts and ideas are treated with the upmost respect and are incorporated into the site as much as possible.<p> Even the Content Management Systems (CMS) we build are all individually designed so that even the back end of the site works according to the client’s wishes. The reason we do this is that every website built will be different. Our view here at design-flow is that all CMSs built need to be custom-made for the individual. Another advantage of building the CMSs is that they will be end-user friendly with only the features requested available for use and no added extra components, superfluous and liable to create complications in the future. "; break; case 3: echo "<h1>what we offer</h1><br /> Of course we offer basic websites and additionally we can build bespoke Content Management Systems according to the exact needs of the client. As we know at design-flow, everybody’s site is different and will need updating in different ways. This is why we do not build one Content Management System and try to convince the client this is what they need. We will find out what specific needs the system has and build it to the exact required specification. In doing this the client will always have the complete control over what the website is displaying and how it will be updated. We also offer ecommerce sites so that our clients are able to sell products directly online."; break; case 4: echo "<h1>New Businesses</h1><br /> Welcome to our site here at design-flow Liverpool. We are a web design company that pride ourselves in producing functional and user friendly websites. We take great care in making sure that the websites we produce fit the needs of the client and the people who will be using the website on a regular basis. When we take on a website, we not only take on the responsibility to produce a website that is functional but we also feel it is our duty to try and understand the wishes of the client. In order for this to take place the client’s role in the site’s development is integral: from start to finish we will involve the client.<p> To do this, we must first build a good understanding of our client’s needs and wishes for the site. The way to facilitate this is by meeting with the client face to face to nurture a good relationship."; break; } ?>
  6. here is what is being shown from the the above variable when being displayed on the html page
  7. hello everyone. i am having a problem sending semi colons, commers etc through an ajax page using php. when the text is displayed on the page i am getting squares and other symbols instead. i have had this problem before and i am pretty sure a fixed it with adding and stripping slashes from the text as it was sent but cannot for the life of me find the fixed version of this code. any help on this would be great. here is the section from the php <?php $cOption = $_GET['o']; switch($cOption) { case 1: echo "<h1>who we are</h1><br /> Welcome to our site here at design-flow Liverpool. We are a web design company that pride ourselves in producing functional and user friendly websites. We take great care in making sure that the websites we produce fit the needs of the client and the people who will be using the website on a regular basis. When we take on a website, we not only take on the responsibility to produce a website that is functional but we also feel it is our duty to try and understand the wishes of the client. In order for this to take place the client’s role in the site’s development is integral: from start to finish we will involve the client.<p> To do this, we must first build a good understanding of our client’s needs and wishes for the site. The way to facilitate this is by meeting with the client face to face to nurture a good relationship."; break;
  8. why is it that the simplest way to make things work is generally the last thing you find. i have spent a few days reading up on .htaccess files and speaking to the hosting company to find out if i could use them (dont get me wrong i like learning new things) but i have just found this piece of code which i think is what PFMaBiSmAd hinted at in an earlier post which does exactly what i need it to. ini_set('memory_limit', '128M'); all the searching i have done was only telling me that i could only change the memory limit by accessing the php.ini file or through the use of a .htaccess file. the line of code above will simply set the limit for that script only thus allowing larger files to uploaded when they are needed. thanks for any replies from anyone who has helped on this topic.
  9. i will try to answer your four points as best i can a) as far as i am aware the file is a .htaccess file inj the folder it is stored in the file type states HTACCESS FILE, is there not a standard naming convention for these files? b)when i spoke to the people from the hosting company about 20min ago they told me i dont have acess to the php.ini file but i should be able to override the the memory limit with a .htaccess file. c)how can i find out if something else is overriding the .htaccess file i have uploaded d)According to the person i spoke to i can override the phph.ini file with a .htaccess file. As for web server being Apache and running php as an Apache module i am unsure but i will past anything here which i thing might let you know (do not know to much about servers still on a very steep learning curve, this was not even looked at in uni with the course i done. as i am with .htaccess files). Linux rubidium.webfusion.co.uk 2.4.32-pipex.1.1smp #1 SMP Thu Feb 23 12:11:21 GMT 2006 i686 Apache/1.3.29 (Unix) (Red-Hat/Linux) Chili!Soft-ASP/3.6.2 mod_ssl/2.8.14 OpenSSL/0.9.6b PHP/4.4.9 FrontPage/5.0.2.2510 i could pm you with a link to the php info file if that would be easier for you as i know nothing on the server.
  10. does anybody know if this code is correct i am trying to increase the memory limit made available for the uploading of files from a php script. i have spoke to my hosting company who said i cannot have access to the php.ini file but i can use .htaccess files to override this for my website. i have created this .htaccess file but it is still telling me that i have exceeded the allowed memory allocation of 16mb could someone please tell me where i am going wrong with this. here is what l have in the .htaccess file php_value post_max_size 128M php_value upload_max_filesize 128M php_value memory_limit 300M there is nothing else to the file just this, does it need anything else to make it work. i have never used these files before and would like some pointers on why it might not be working. the server has php 4.4.9 installed it says when i run phpinfo.php
  11. i have done some searching around an have seen in alot of places people saying that this can be done with a .htaccess file, which is something that i have not used before. from what i have read about i think all i would need to put in to this file would be the following code php_value memory_limit 96M this file should then go into the main folder for the site and it will give all folders and sub-folders from that site the memory limit of 96Mb for file uploads. is that correct or have i gone wrong somewhere along the line.
  12. i have not got access to the php.ini file on the server so i cannot do it that way.
  13. is there not a way round this as other sites like facebook allow uploads and not that i have uploaded images to these sites but i have not heard of any problems with from anyone usiing those sites. i have just spoke to my hosting company and they said that the limit was set tto 8Mb for uploads.
  14. i have an image upload script for uploading images to a database which works well with images under 1Mb but when i try to upload images over this i get this error message Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 13056 bytes) in /home/acmeart/public_html/pip_new/cms/events_image.php on line 56 from this error message i can see that it is telling me that 16Mb of allowed memory has been used and it tried to allocate more. why is it using so much memeory when the image is only 3.25Mb here is the code i am using. <?php $id_num = $_POST['id_num']; set_time_limit(0); $link = mysql_connect(xxxxxx, xxxxxxxxxxx, xxxxxxxxxx) or die("Could not connect to host."); mysql_select_db(xxxxxxxx) or die("Could not find database."); //define a maxim size for the uploaded images define ("MAX_SIZE","28800"); // define the width and height for the thumbnail // note that theese dimmensions are considered the maximum dimmension and are not fixed, // because we have to keep the image ratio intact or it will be deformed define ("WIDTH","150"); define ("HEIGHT","120"); // this is the function that will create the thumbnail image from the uploaded image // the resize will be done considering the width and height defined, but without deforming the image function make_thumb($img_name,$filename,$new_w,$new_h) { //get image extension. $ext=getExtension($img_name); //creates the new image using the appropriate function from gd library if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $src_img=imagecreatefromjpeg($img_name); if(!strcmp("png",$ext)) $src_img=imagecreatefrompng($img_name); if(!strcmp("gif",$ext)) $src_img=imagecreatefromgif($img_name); //gets the dimmensions of the image $old_x=imageSX($src_img); $old_y=imageSY($src_img); // next we will calculate the new dimmensions for the thumbnail image // the next steps will be taken: // 1. calculate the ratio by dividing the old dimmensions with the new ones // 2. if the ratio for the width is higher, the width will remain the one define in WIDTH variable // and the height will be calculated so the image ratio will not change // 3. otherwise we will use the height ratio for the image // as a result, only one of the dimmensions will be from the fixed ones $ratio1=$old_x/$new_w; $ratio2=$old_y/$new_h; if($ratio1>$ratio2) { $thumb_w=$new_w; $thumb_h=$old_y/$ratio1; } else { $thumb_h=$new_h; $thumb_w=$old_x/$ratio2; } // we create a new image with the new dimmensions $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); // resize the big image to the new created one imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); // output the created image to the file. Now we will have the thumbnail into the file named by $filename if(!strcmp("png",$ext)) imagepng($dst_img,$filename); else imagejpeg($dst_img,$filename); if (!strcmp("gif",$ext)) imagegif($dst_img,$filename); //destroys source and destination images. imagedestroy($dst_img); imagedestroy($src_img); } // 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 error 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['news_image']['name']; // if it is not empty if ($image) { // get the original name of the file from the clients machine $filename = stripslashes($_FILES['news_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, print an error message //and will not upload the file, otherwise we continue if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo '<h1>Unknown extension! Please use .gif, .jpg or .png files only.</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=getimagesize($_FILES['news_image']['tmp_name']); $sizekb=filesize($_FILES['news_image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($sizekb > MAX_SIZE*1024) { echo '<h1>You have exceeded the 1MB size limit!</h1>'; $errors=1; } $rand= rand(0, 1000); //we will give an unique name, for example a random number $image_name=$rand.'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newsname="image/".$image_name; $newsname2="image/thumbs/thumb".$image_name; $newsname3="cms/image/thumbs/thumb".$image_name; $copied = copy($_FILES['news_image']['tmp_name'], $newsname); $copied = copy($_FILES['news_image']['tmp_name'], $newsname2); $sql="UPDATE news SET image= '$newsname3' WHERE id= '$id'"or die(mysql_error()); $query = mysql_query($sql)or die(mysql_error()); //we verify if the image has been uploaded, and print error instead if (!$copied) { echo '<h1>Copy unsuccessfull!</h1>'; $errors=1; } else { // the new thumbnail image will be placed in images/thumbs/ folder $thumb_name=$newsname2 ; // call the function that will create the thumbnail. The function will get as parameters //the image name, the thumbnail name and the width and height desired for the thumbnail $thumb=make_thumb($newsname,$thumb_name,WIDTH,HEIGHT); } } } } //If no errors registred, print the success message and show the thumbnail image created if(isset($_POST['Submit']) && !$errors) { echo "<h5>Thumbnail created Successfully!</h5>"; echo '<img src="'.$thumb_name.'">'; } echo "<form name=\"newad\" method=\"post\" enctype=\"multipart/form-data\" action=\"\">"; echo "<input type=\"file\" name=\"news_image\" >"; echo "<input type=\"hidden\" name=\"id_num\" value=\"$id_num\" />"; echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"250000\" />"; echo "<input name=\"Submit\" type=\"submit\" id=\"image1\" value=\"Upload image\" />"; echo "</form>"; echo "<br />"; echo "<br />"; echo "<h3>Please ensure that the images uploaded are under 650kb in size.</h3>"; echo "<h3>This is due to a size limit on the upload to prevent security issues.</h3>"; echo "<br />"; echo "<a href='index.php'> <h3><< Add Another Article</a></h3>"; ?>
  15. why is it that the db connection details have to go before the mysql real escape string statement?
×
×
  • 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.