Jump to content

Chappers

Members
  • Posts

    119
  • Joined

  • Last visited

    Never

Everything posted by Chappers

  1. Both methods work perfectly, many thanks. The space was added to show where I wanted the two elements to join, but to make things clear I had to leave a space otherwise the variable would be read as $urlcss... Best regards, James
  2. D'oh! Still can't get it working, because my code is like this: [code]<?php $url = "http://example.com/"; ?> <table align="center" width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td align="center"> <?php echo "<link rel='stylesheet' href='$url css/styles.css' type='text/css'>"; ?>[/code] Where I don't want the current space between [b]$url[/b] and [b]css/styles.css[/b] Any ideas please? Enjoy your night out ;-)
  3. Thanks a lot for that quick reply, much appreciated. All the best, James
  4. Hi, Just a small thing - I've got this code: [code]<?php $url = "http://example.com/"; echo "$url images/example.jpg"; ?>[/code] Now that'll echo: http://example.com/ images/example.jpg But, of course, I don't want a space between the [b]example.com/[/b] and the [b]images/example.jpg[/b]. If I just put the echo as: $urlimages/example.jpg, it doesn't work of course. What's the proper way of doing this? Many thanks, James
  5. Right, I did it this way, although not sure if it's the right way: [code]<?php $file = $_REQUEST['file']; $contents = readfile($file) or die('couldnt read file'); echo $contents; ?>[/code] And it opened a new page stating 'couldnt read file'. If I simply left the code alone and removed the headers and @: [code]<?php $file = $_REQUEST['file']; readfile($file); ?>[/code] I just got a blank screen. If this isn't what you meant, could you supply the code to try, please?
  6. Thanks again for the help, I appreciate it. Tried removing headers so file read like: [code]<?php $file = $_REQUEST['file']; @readfile($file); ?>[/code] But just get a blank page. Not sure if that's exactly what you meant... sorry, still struggle with PHP. Then did next suggestion of replacing @readfile with the code supplied, so it looked like: [code]<?php $file = $_REQUEST['file']; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); $handle = fopen($file, 'r') or die('couldnt open file'); $contents = fread($handle, filesize($file)) or die('couldnt read file'); fclose($handle); echo $contents; ?>[/code] And it worked perfectly, the file downloaded and I opened the image to check it and it was fine. So just curious, can I leave the code as above since it works? And, out of curiosity, why doesn't @readfile work, yet the code you gave me with which to replace readfile works perfectly? Thanks for time and help.
  7. Thanks for the link. The code it gives is: [code]<?php $file = $_REQUEST['file']; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); @readfile($file); ?>[/code] Where the download link would be something like: a href=image.php?file=/images/example.jpg It gives the same results as original code I posted though: downloaded file is 0Kb, as though it's not finding the jpeg image in the first place and so is making an image with the name I tell it to use, but which consists of no data. For the code above, I changed content-type to image/jpeg. Any idea what I'm doing wrong?
  8. Hi everyone, I'm trying to force the browser to bring up a 'save as...' dialog box when a download link is clicked which is linked to a jpg image file, instead of opening the image in the browser. After searching the net, I found the same snippet of code all over the place for doing this, but it won't work properly for me. Here's how the href link looks for a given image file: [code]<a href="image.php"><img src="images/save.gif" alt="save"></a>[/code] So when the link is clicked, it references the image.php file, inside which is the following: [code]<?php header('Content-disposition: attachment; filename=mypicture.jpg'); header('Content-type: image/jpeg'); readfile('images/mypicture.jpg'); ?>[/code] Now, I know that there can be no blank lines after the php code, or garbage may be added to the image file as it's rebuilt. The problem is that although this works and brings up a save as box, when you save the file, it's a 0Kb file. It's the same behaviour as happens if you tell it to use a file that doesn't exist in the 'readfile' area. But I know the file is there and the address for the image file is correct and is how it's used on the rest of the site. I have the root directory on the server, with the "images" folder in the root, so image links are usually simply a href=images/whatever.jpg. Can anyone help shed light on what's going wrong please?
  9. Hi, I'm trying to set different styles for links on my website, depending on whether they're menu links, links on a certain page, etc. Here's the CSS: [code]a:link, a:visited{ font:14px Verdana, Helvetica, sans-serif; color: #00FF00; text-decoration: none; } a:hover{ font:14px Verdana, Helvetica, sans-serif; color: #FF0000; text-decoration: none; } a.spiritlink:link, a.spiritlink:visited{ font:11px Verdana, Helvetica, sans-serif; color:#00FF00; text-align:justify; text-decoration: none; } a.spiritlink:hover{ font:11px Verdana, Helvetica, sans-serif; color:#FF0000; text-align:justify; text-decoration: none; } a.menu:link, a.menu:visited{ font:12px Verdana, Helvetica, sans-serif; color: #166503; width:150; margin-left: 6px; text-decoration: none; filter:Glow(color=#4FFF25, strength=5); } a.menu:hover{ font:12px Verdana, Helvetica, sans-serif; color: #FF0000; width:150; margin-left: 6px; text-decoration: none; filter:Glow(color=#FC8322, strength=5); }[/code] Trouble is, the basic link style (a:link) has an effect on all the link classes I create afterwards. I can remove the basic style for "a" links, but then it just uses the default font type, size and colours of IE anyway. If I set a:link, etc., to 14px font size, then my a.menu class displays at that size too, regardless of having a separate font size value entered for that class. Is there a way around this that will let me set unique "a" classes for links that conform to whatever parameters I set (font, size, glow, padding, hover effects...) without being affected by the default "a" class? Thanks, James
  10. Hi I'm using this simple upload form to upload image files to a folder on my server, and I'm trying to add another form input in the form of a text input. I wanted to have this text input added to the first part of an uploaded file's name so I know who's sent it, but I can't work out how to do it. I've tried and tried, and I've searched the net but it's not easy to search for. [code]<?php if(!isset($_POST['upload'])) { echo ' <form name="upload" enctype="multipart/form-data" method="POST" action="'.$_SERVER['REQUEST_URI'].'"> <input type="file" name="file" value=""><br> Name: <input type="text" name="name" size="20"> <br><input type="submit" name="upload" value="Upload"> </form> '; } else { $yourdomain = 'http://example.net/'; $uploaddir = 'files/'; $filename = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $tmpname_file = $_FILES['file']['tmp_name']; $date_file = date(dmY); if($filesize > '102400') { echo "File is too big!"; } else { move_uploaded_file($tmpname_file, "$uploaddir$date_file$filename"); echo "File uploaded Successfully.<br />URL to your file: <a href=\"http://example.net/".$uploaddir.$date_file.$filename."\"> http://example.net/".$uploaddir.$date_file.$filename."</a>"; }   } ?>[/code] The field I've added can be seen above as :[code]Name: <input type="text" name="name" size="20">[/code] Could someone please tell me how I pass this to be added to the file's name? I can work out what to do once I've made it a variable ($blahblah) but don't know how to make it one. I assumed it had to be done in the section of code where the $filename, $filesize are done... Thanks
  11. Hi, no offense taken; I agree with what you say, and must admit I realised it myself shortly after posting and had planned to delete this topic, but as it was so late, I ended up going to bed. I didn't mean to come across as asking someone to write the code for me, but for some strange reason I had the silly belief that it would be an uncommon request and there wouldn't be such a thing around on the Internet, but that maybe someone had written one themselves and would care to share. I'm not sure why I thought this, because I've taken your advice and found many scripts. Not like me to ask first, Google after, so I apologise. I'm now going to try adding a few things to the script, such as verifying the file is an image, etc., and adding muliple upload fields so more than one image can be uploaded at a time. There is one question I have, though: all the scripts I have found upload the image to a directory. As I'd like also to try having a comment form that uploads messages to a file, is there a simple way I can change it from uploading to a directory, to inserting code into a .php file on the server? Or would I have to insert it into a MySQL table, and then use another page to display any messages from there? Thank you, James
  12. Hi I want to have an upload facility on a page of my site which lets users upload an image that will be stored in a folder on the server, so I can grab the pic when I want and host it on the page later. I did originally want something that instantly put the image on the page, but then thought better of it knowing the amount of porn pics that'd probably be uploaded just because they can. I can't use an email form unfortunately, because the free host I'm with has safe mode on, and smtp (send_mail, or something) disabled to stop such things, for spam purposes - but this image upload idea should still be possible, no? I've just thought, if this is possible, maybe I can get around the problem of not being able to use an email form by having a form that sends the info to a file, which I could then bring up (but not publicly list in the menu) and see all messages sent? I have MySQL available and am using it for a comment form at the moment for adding comments to pages. Only trouble is I have to go into PHPAdmin to delete messages, which I'd have to do with the email type form idea too I s'pose. Anyway, any ideas welcome. Thanks, James
  13. Thanks for that info Chris, it's helped broaden my knowledge of CSS a bit more. I'll implement it like you've said, but first there's one other thing I don't understand if you wouldn't mind shedding some light please? The styles are within the included [i]comment form[/i] at the moment, but it'd be easier for me if they were in a separate stylesheet, which is why I wanted to know how to do the above. Thing is, the comment form includes BBCode so people can add formatting to their comments. The styles for this formatting are put like this in the comment form code: [code]?> <style type="text/css"> <!-- body { font: 12px Verdana, Helvetica, sans-serif; } .bold { font-weight: bold; } .italics { font-style: italic; } .quotebody { background-color: #FFFFFF; font-family: Verdana, Courier new, courier, mono; font-size: 11px; color: #660002; border: 1px solid #BFBFBF; } etc... etc... --> </style>[/code] And later in the code more styles are laid out in this fashion, for the actual layout of the comment form itself, but they are not commented out, like the above ones. If I remove the [code]<!-- -->[/code] from the above, it then messes up the layout of the comment form and the main page within which the form is included. How would I go about adding the commented-out style code above into the main stylesheet without it messing other things up? And to help me understand, how come it's commented out yet still working, and why aren't the rest of the styles later in the code commented out?
  14. Hi I want to use two different stylesheets with on page. I've got a php include function adding a comment form to one of my web pages, and would like this comment form to have its own stylesheet, rather than make include things for the comment form into the main site's stylesheet. Is this possible? I assume it's important, if two can be used, to make sure that the two don't have similar things, like both having settings for "body", etc. Unless it's possible to keep one working just for the comment form, by applying the sheet before the comment code is added, and closing it afterwards? The main page has the stylesheet linked like this: [code]<style type="text/css" media="all">@import "css/style.css";</style>[/code] And that's it. Many thanks for any help, James
  15. Thanks for your reply. [quote]lol <table width="100%" align="center" cellspacing="0" cellpadding="0" border="0" bordercolor="#000000"> If there’s no border, then there is no bordercolor![/quote] Umm, not sure why you find a perceived mistake by a confessed amateur as funny, but there is a reason I've placed a bordercolor there even though the border is off: when building a page, I like to have the border on for some parts so that I can see exactly what I'm doing, and where I may have made a mistake in the layout of the cells. I find a black thin border easier to work with than the default light-grey one. The border is set on and off depending on what I'm doing at the time. When a page is finished I 'clean' the code up. Incidentally, you'll notice that the same code is repeated in the top and bottom boxes, albeit for the bit of extra code in the bottom box, which handles the red bar I am referring to. If you look, the top box does not have the [i]bordercolor[/i] present, yet the bottom one does for the same table. This is because when I pasted the top lot of code, I had the presence of mind to pre-empt someone ridiculing the bordercolor with border turned off, and wanted to avoid needing to explain myself, so deleted it. However, I forgot to remove it when pasting the same code into the bottom box.  ;) Anyway, here is the website link: [url=http://jamesqb.xlphp.net/index.php]http://jamesqb.xlphp.net/index.php[/url] You'll see two little red images at the top of the white window... these are the left and right ends to what should be a long red banner. The center section, which should consist of a 1x16 pixel image repeating along the length of the column, is not showing at all. The long red banner beneath is to show what happens when the border is turned on for that table. I'm sure I'm doing something silly, or not allowable/normal in HTML. Thanks again for your reply. James
  16. Hi Can't get to grips with this seemingly simple problem! I'll see if I can explain it so my madness makes some sense. Bear with me, coding (even just HTML) isn't my strong point. I've set out a webpage so that there is a middle section giving the appearance of a sheet of paper on the page, within which is the content of the page. So basically it's one long column of background colour, then a few images to give borders to the middle section, then another long column. To get the top of this worked out I've got this code: [code]<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"> <tr> <td colspan="5">&nbsp;</td> </tr> <tr> <td class="columns" width="18%"></td> <td class="layout-top-left"></td> <td class="layout-top-middle"></td> <td class="layout-top-right"></td> <td class="columns" width="18%"></td> </tr> <tr> <td class="columns" width="18%"></td> <td class="layout-left-side"></td> <td align="center" bgcolor="#FFFFFF"> <!-- CONTENT START--> <table width="100%" align="center" cellspacing="0" cellpadding="8" border="0"> <tr> <td>CONTENT</td> </tr> </table> <!-- CONTENT END --> </td> <td class="layout-right-side"></td> <td class="columns" width="18%"></td> </tr> <tr> <td class="columns" width="18%"></td> <td class="layout-bottom-left"></td> <td class="layout-bottom-middle"></td> <td class="layout-bottom-right"></td> <td class="columns" width="18%"></td> </tr> </table> </body>[/code] Where columns create the left and right main columns of background colour, and the layouts are two corner images and one center image which repeats horizontally to fill the whole column between corner images. The classes are in a CSS file as: [code]td.columns{ background-image: url(/images/layout/columns.gif); background-repeat: repeat; } td.layout-top-left{ background-image: url(/images/layout/top-left.gif); background-repeat: no-repeat; height: 12px; width: 12px; } td.layout-top-middle{ background-image: url(/images/layout/top-middle.gif); background-repeat: repeat-x; height: 12px; }[/code] and so on for them all. I wanted to add a coloured bar 16 pixels high to run along the 'piece of paper' to act as a separator for a logo I planned to add later. So I created a left image, center image to repeat horizontally, and right image to end the bar. I then did entries into the CSS file in the same manner as above and added the HTML to this section: [code]<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <table width="100%" align="center" cellspacing="0" cellpadding="0" border="0" bordercolor="#000000"> <tr> <td colspan="5">&nbsp;</td> </tr> <tr> <td class="columns" width="18%"></td> <td class="layout-top-left"></td> <td class="layout-top-middle"></td> <td class="layout-top-right"></td> <td class="columns" width="18%"></td> </tr> <tr> <td class="columns" width="18%"></td> <td class="layout-left-side"></td> <td align="center" bgcolor="#FFFFFF"> <table width="100%" align="center" cellspacing="0" cellpadding="0" border="0"> <tr> <td class="layout-bar-left"></td> <td class="layout-bar-middle"></td> <td class="layout-bar-right"></td> </tr> </table> <br> <!-- CONTENT START--> <table width="100%" align="center" cellspacing="0" cellpadding="8" border="0">[/code] with all the rest of the code unaltered beneath this too. But the middle section is not showing (layout-bar-middle) even though the code in the CSS file is the same as for the other middle section of the 'paper' border, set to background-repeat: repeat-x. However, if I turn the table border on to "1" for the table containing the red bar sections, it shows and repeats as it should do, with the only trouble being the gaps between the edge images due to the border! Otherwise, it just shows the left edge image in its correct position, a blank space going halfway along the table, then the right edge image, which is therefore nowhere near where it should be (end of TD). What have I done wrong? Why does it work with the other layout which makes the 'paper' borders? Thanks for any help, James
  17. Hi there I'm using the following method of having the background of menu links change colour when the mouse is over the link, and of having a different colour text and background when the link refers to the current page: Each page has: [code]<?php $thisPage="home"; ?>[/code] at the very top, where [i]home[/i] is replaced by a different name for each page. The menu then has the links done like this: [code]<td align="left"> <span<?php if ($thisPage=="home") echo " id=\"currentpage\""; else echo " id=\"menu\"";?>> <a href="http://www.example.com/index.php">Home</a></span> </td>[/code] So if the current page is [i]home[/i], the span ID is currentpage for the following link. Otherwise it is given the [i]menu[/i] ID. The IDs are in the stylesheet thus: [code]#menu a:link{ font:11px Verdana, Helvetica, sans-serif; color: #FFFFFF; background-color: #788D9F; text-decoration: none; } #menu a:visited{ font:11px Verdana, Helvetica, sans-serif; color: #FFFFFF; background-color: #788D9F; text-decoration: none; } #menu a:hover{ font:11px Verdana, Helvetica, sans-serif; color: #FFFFFF; background-color: #CC2020; text-decoration: none; } #currentpage a{ font:11px Verdana, Helvetica, sans-serif; color: #788D9F; background-color: #FFFFFF; text-decoration: none; }[/code] And this all works a treat. The trouble is, I wish to have the whole TD in which the menu link is placed have a background colour which changes when the mouse is over the link. Ideally I could do with having the benefits of the stylesheet, so I can add borders, change text colour, etc., when a link is the current page or being highlighted by the mouse cursor being over it. At the moment it looks a bit bare and odd having the background colour only behind the actual words of the menu link, especially as each link word is of a different length... looks a bit messy. Any ideas how I could do this, or maybe there's a completely different method for all of the above that incorporates what I want to do? Many thanks in advance. Regards, James
  18. Hi Thank you both for your replies. As often happens, some time after posting I found a comment script which I then implemented. I thought I'd searched everywhere (had been searching on Google for hours) but just goes to show how a different search term here and there can make a difference  :-\ For anyone interested, it can be found here: [url=http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php]http://www.zimmertech.com/tutorials/php/25/comment-form-script-tutorial.php[/url] Thanks again  :)
  19. Hi I'm trying to find a good script that will allow me to put a little 'add your comments' box on any page on my website. I tried guestbook scripts, but they'd need separate MySQL tables creating for each page, and a new installation for each one. I need something I can add quickly and easily to any page I create, which will then allow comments to be added to that page, and shown on that page - but only that page. Not something that shows the collective comments from every page that has the facility. Nothing fancy, anything basic would do. I just can't seem to find anything and my knowledge of PHP is still far too limited for making something myself. Could someone recommend something suitable please? Many thanks in advance, James
×
×
  • 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.