Jump to content

spikypunker

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

Everything posted by spikypunker

  1. Hey guys Am developing a user small scale user community, have asked a few questions for it so far, and it's going real well. I'm not very advanced with my PHP and have had this problem in the past but have just lived with it before but now i really wanna sort it out. When someone makes a profile they can put in thier details, most being single lines. However there is an About Me box where they invariably end up putting in some parabreaks. When this goes into the database they are still present but obviously when its read back into a page it ignores the returns so i get a chunk of text. I'm not 100% but it used to be a simple case of putting the text inside a <p> tag which used to keep the formatting but it's changed now. Is there a simple way to achieve this? Peace
  2. Yeh you cant put the " marks in after a PRINT command cause it opens and closes the print command. In case you ever do need to do something with a " you can in fact replace it with '
  3. cheers. The only thing is tho, the page with the comparison on isnt actually being reached! I dont think the Form is allowing the upload to the PHP temp folder. After you select the file (mp3) the page thinks for a bit then just refreshes.... How do i test that a file has uploaded to php temp area?
  4. Cheers for the help guys, tried to test the type and still doesnt actually ever get to that page! I'm uploading the file using the following Form, should work fine! Could it have something to do with our PHP server config? There are time limits etc.. What happens is that you choose the MP3 to upload and it thinks for a minute or two then just refreshes! Here is the Form: <? $user = $_GET['user']; ?> <form enctype="multipart/form-data" action="musicuploader.php?user=<? echo "$user" ?>" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="32000000" /><br> <input name="uploaded_file" type="file" /><br><br> <input type="submit" value="Upload" /> </form> These are the bits in the config i think are relevant: (i havent missed of the units of time for the Resource limits, there isnt any! Also there is the following text, bearing in mind i havent taken this into consideration when i coded the working image uploader??? Regarding the Error message, there is a message but i havent included all the code on the first post. Thanks for any help!!! peace
  5. Hey guys, i have a working image uploader but i need to convert this to a music uploader, i dont see any problems except for one line, which i dont know the equivelant from image to mp3? Here is the original line: if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 1000000)) { $newname = dirname(__FILE__).'/userpics/'.$filename; I've tried this: if (($ext == "mp3") && ($_FILES["uploaded_file"]["type"] == "music/mp3") && ($_FILES["uploaded_file"]["size"] < 32000000)) { $newname = dirname(__FILE__).'/music/'.$filename; But all that happens is the previous pages loads for a bit (the page with the FORM on) and then doesnt forward to this page, does this mean that the file isnt even getting to this page at all? I've cheked the PHP settings and theres a 32M limit so i set mine to the same... Any ideas?
  6. hahahaha what a chump i am, i'm still happy tho cause now it's working!!! WOOOOOOOOOO )))) $query = " UPDATE USER SET image = '$filename' WHERE user='$user' "; Cheers for the help matey, peace
  7. All it is is this bit: $query = "INSERT INTO USER (image) VALUES ('$filename') WHERE user='$user' "; it should work, it's rreeeally simple but no joy! IF i take out the WHERE user='$user' bit then it does actually insert into the mysql, it just starts a new entry... I've done echo's of both variables and they come out fine. I've even tried replacing the $user with an actual column name that i know is there!! Why doesnt it work!!!!!! Here is the rest of the code (which all works perfectly, the image uploads just the MySql doesnt update) <?php $user = $_GET['user']; if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 1000000)) { $newname = dirname(__FILE__).'/userpics/'.$filename; if (!file_exists($newname)) { if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { mysql_connect ("localhost","",""); @mysql_select_db("") or die ("unable to connect"); $query = "INSERT INTO USER (image) VALUES ('$filename') WHERE user='$user' "; mysql_query($query); mysql_close(); echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 350Kb are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?>
  8. haha genius, you're right it does work! Well what a waste of everybodies time! lol sorry guys! But at least this shows other people how to do a simple php uploader, and also that Super Global variables are still allowed on servers! I've learnt something anyway Cheers man.
  9. Hey Guys, im developing an online video showcase site, this is an extension of our main website. I've used a simple php file uploader before and am wondering if it would work in the same way nowadays due to global variables being turned off most servers? The method i would try would be: <?php if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 350000)) { $newname = dirname(__FILE__).'/upload/'.$filename; if (!file_exists($newname)) { if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { echo "It's done! The file has been saved as: ".$newname; } else { echo "Error: A problem occurred during file upload!"; } } else { echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists"; } } else { echo "Error: Only .jpg images under 350Kb are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> Am i right in thinking this would not work anymore?? Any help muuuuch apperciated ) Peace
  10. well i phoned em up and they agree that it should work lol, they also suggested i try the CPANEL apache handler thing so i put that in to handle it with no joy! This is the source of the .html page: ARGGGHHH!!! :os lol, any ideas?? Is it because i'm typing the URL in rather than linking to the .html file i need to be changed to .php?
  11. Hey Guys, have recently sorted out a php script with the kind help of your board. I was told that i can get round the problem of having to convert all my .html files to .php ones by setting up a .htaccess file with the following code on it: RemoveHandler .html .htm AddType application/x-httpd-php .php .htm .html But it doesnt seem to be having and effect on the html pages, any ideas as to what i'm doing wrong? I've placed the file in the same directory as the sites files. Plus have contacted the hosters and it's definately an apache server, what am doing wrong??? cheers guys, peace
  12. Haha! My fault, i dunno what happened but i'd put the function in wrong! It's now working and i'm well chuffed!!! WOOOOO, for anyone who wnats to use this script, here is the final working two pages.. ad_function.php <?php function ads(){ mysql_connect("localhost", "****", "****"); @mysql_select_db("****") or die ("unable to connect"); $limit = 8; //number of ad spaces on the page $large = 2; //number of full sized add spaces on your page $small = $limit - $large; $query_large = mysql_query("SELECT * FROM ads WHERE large = \"YES\" ORDER BY Rand() LIMIT $large"); $i=0; while($sql=mysql_fetch_array($query_large)){ if($i < $large){ $ad["ad"][$i]=$sql["full_ad"]; //URL for full sized ad banner $ad["url"][$i]=$sql["add_url"]; //URL for full sized ad banner to redirect to website $i++; } } $query_small = mysql_query("SELECT * FROM ads WHERE large = \"NO\" ORDER BY Rand() LIMIT $small"); $i=0; while($sql=mysql_fetch_array($query_small)){ if($i < $small){ $ad["ad"][$i+$large+1]=$sql["small_ad"]; //URL for small sized banner $ad["url"][$i+$large+1]=$sql["add_url"]; //URL for small sized ad banner to redirect to website $i++; } } return $ad; } ?> rotator.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Ad rotator test</title> </head> <body> THIS IS A TEST PAGE<br /><br /> <?php require_once("ad_function.php"); ?> <?php $ad=ads(); ?> <br /><br /> <a href="<?php echo $ad['url']['0']; ?>"><img src="<?php echo $ad['ad']['0']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['1']; ?>"><img src="<?php echo $ad['ad']['1']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['2']; ?>"><img src="<?php echo $ad['ad']['2']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['3']; ?>"><img src="<?php echo $ad['ad']['3']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['4']; ?>"><img src="<?php echo $ad['ad']['4']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['5']; ?>"><img src="<?php echo $ad['ad']['5']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['6']; ?>"><img src="<?php echo $ad['ad']['6']; ?>"></img></a><br /> <a href="<?php echo $ad['url']['7']; ?>"><img src="<?php echo $ad['ad']['7']; ?>"></img></a><br /> </body> </html> Thanks many times over, to the kind person who has helped me on this, and also to the person who chipped in with an alternative, which is also worth a look for people trying to run ads. Peace!!!
  13. Ahh i see, sorry i've been not paying as much attention to the code as i should have. I see the LARGE = YES but has been removed from the PHP function page? Here is the function page... <?php function ads(){ mysql_connect("localhost", "maddogma_admin", "connect"); @mysql_select_db("maddogma_ads") or die ("unable to connect"); $limit = 8; //number of ad spaces on the page $large = 2; //number of full sized add spaces on your page $query = mysql_query("SELECT * FROM ads ORDER BY Rand() LIMIT $limit"); $i=0; while($sql=mysql_fetch_array($query)){ if($i < $large){ $ad["ad"][$i]=$sql["full_ad"]; //URL for full sized or large ad banner $ad["url"][$i]=$sql["ad_url"]; //URL for full sized or large ad banner to redirect to website $i++; }else{ $ad["ad"][$i]=$sql["small_ad"]; //URL for small sized or cut down ad banner $ad["url"][$i]=$sql["ad_url"]; //URL for full sized or large ad banner to redirect to website $i++; } } return $ad; } ?> All that needs to happen now is that the first IF part (the large ads) need to only select from the DB where column LARGE is equal to YES, then only select the ELSE bits where the LARGE is equal to NO. I'm not too sure how to code this, can anyone help finish this off? Many thanks and kind regards!
  14. Woo hoo!! It's nearly there man, it's now bringing in the images! and the URLS! The only glitch now is the Blanks it's still bringing in from the DB, so is this a problem with the Large = YES bit?
  15. Wkd man, it's now getting all the rows in but still not putting anything into the IMG SRC bit or the URL, also it's pulling in the BLANKS meaning the IF LARGE == YES is not working? I dunno man but i've played with it and cant get any further! Nearly there tho, really appreciate everything so far!
  16. Oh yeah also, here is a copy of my mysql table, i've checked that the linking details are correct (plau the print_r showed data from the table)
  17. OK dude, done that, here's where i put the print_r <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Ad rotator test</title> </head> <body> THIS IS A TEST PAGE<br /><br /> <?php require_once("ad_function.php"); ?> <?php $ad=ads(); Print_r ($ad); ?> <a href="<?php $ad['url']['0'] ?>"><img src="<?php $ad['ad']['0'] ?>"></img></a><br /> <a href="<?php $ad['url']['1'] ?>"><img src="<?php $ad['ad']['1'] ?>"></img></a><br /> <a href="<?php $ad['url']['2'] ?>"><img src="<?php $ad['ad']['2'] ?>"></img></a><br /> <a href="<?php $ad['url']['3'] ?>"><img src="<?php $ad['ad']['3'] ?>"></img></a><br /> <a href="<?php $ad['url']['4'] ?>"><img src="<?php $ad['ad']['4'] ?>"></img></a><br /> <a href="<?php $ad['url']['5'] ?>"><img src="<?php $ad['ad']['5'] ?>"></img></a><br /> <a href="<?php $ad['url']['6'] ?>"><img src="<?php $ad['ad']['6'] ?>"></img></a><br /> <a href="<?php $ad['url']['7'] ?>"><img src="<?php $ad['ad']['7'] ?>"></img></a><br /> </body> </html> And heres the source of what came out: Cheers so much for helping seriously! For extra insight the testpage is here: http://www.maddogmagazine.co.uk/rotator.php
  18. Hey guys, right it's not working currently, one thing i've found is that is does seem to need to be a .php file (how the code is inserted currently anyway) but even with it being a .php file it's still not showing anything where the PHP code is inserted. It's driving me crazy! Could someone please cast an eye over it? here is the file ad_function.php <?php function ads(){ mysql_connect("localhost", "****", "****"); @mysql_select_db("****") or die ("unable to connect"); $limit = 8; //number of ad spaces on the page $large = 2; //number of full sized add spaces on your page $small = $limit - $large; $query_large = mysql_query("SELECT * FROM ads WHERE large = \"YES\" ORDER BY Rand() LIMIT $large"); $i=0; while($sql=mysql_fetch_array($query_large)){ if($i < $large){ $ad["ad"]=$sql["full_ad"]; //URL for full sized ad banner $ad["url"]=$sql["add_url"]; //URL for full sized ad banner to redirect to website $i++; } } $query_small = mysql_query("SELECT * FROM ads WHERE large = \"NO\" ORDER BY Rand() LIMIT $small"); $i=0; while($sql=mysql_fetch_array($query_small)){ if($i < $small){ $ad["ad"]=$sql["small_ad"]; //URL for small sized banner $ad["url"]=$sql["add_url"]; //URL for small sized ad banner to redirect to website $i++; } } return $ad; } ?> And this is the page that i'm using to test the ad display: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Ad rotator test</title> </head> <body> THIS IS A TEST PAGE<br /><br /> <?php require_once("ad_function.php"); ?> <?php $ad=ads(); ?> <a href="<?php $ad['url']['0'] ?>"><img src="<?php $ad['ad']['0'] ?>"></img></a><br /> <a href="<?php $ad['url']['1'] ?>"><img src="<?php $ad['ad']['1'] ?>"></img></a><br /> <a href="<?php $ad['url']['2'] ?>"><img src="<?php $ad['ad']['2'] ?>"></img></a><br /> <a href="<?php $ad['url']['3'] ?>"><img src="<?php $ad['ad']['3'] ?>"></img></a><br /> <a href="<?php $ad['url']['4'] ?>"><img src="<?php $ad['ad']['4'] ?>"></img></a><br /> <a href="<?php $ad['url']['5'] ?>"><img src="<?php $ad['ad']['5'] ?>"></img></a><br /> <a href="<?php $ad['url']['6'] ?>"><img src="<?php $ad['ad']['6'] ?>"></img></a><br /> <a href="<?php $ad['url']['7'] ?>"><img src="<?php $ad['ad']['7'] ?>"></img></a><br /> </body> </html>
  19. Ah thats absolutely brilliant, thanks so much for your help today. I will let you know how i get on! Peace
  20. Ah mate thats wkd, i understand everything you've said so far and think will be able to implement it, the only thing i think i would get stuck on (i know you already helped loads!) is that not all the ads will have BOTH a large and small version, in fact i think each business will have either a large or a small ad on the site, so i'm guessing your method works by a table setup like: Business | Large Ad | Small Ad | URL | shoe shop | images/large.jpg | images/small.jpg | http://www.shoeshop.html | Is this right? If do you think it would be fairly simple to add another field that says large YES/NO Then could add to the first part of the script saying If $ i < $large and Large == YES then.... or something along those lines? Ahhh if you can help me out with that then thats all and i can start making it!! woo!
  21. Awesome man, cheers you legend! I'm gonna setup the DB now, would it be fairly simple to add the URL link to each ad?
  22. Hi Guys I have a website setup which is starting to get some interest, i have a few local small businesses interested in having small ads up on it, and i need to develop a rotator. I know a bit of php and have dropped in ASP bits in the past. I can see how i would develop a simple script by selecting a random row from a table perhaps? But the thing is i already have the pages setup as HTML (i know its a lame reason) but i was hoping there was a way i could do it without having to change ALLL the page names to .php (and then all the link too) Also how would i set it up so that i can have six different ads spaces on the page, and it doesnt select the same ad twice? Also i want to have six ads of one size, then two ads of a different size at the top. Can anyone push me in the right direction? Peace!
  23. wow what a lifesaver! This is just what i need so that it can keep running and give me some time to sort the variables out without the client and account manager adding the pressure! Sweet, thats works perfectly. MANY MANY THANKS p.s Cheers for the extra help there, i will fix the variables tomorrow! For now they can go another day with the slight security risk :-\
×
×
  • 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.