
Snooble
Members-
Posts
311 -
Joined
-
Last visited
Never
Everything posted by Snooble
-
Hello! Thanks in advance.. here's my problem: I want the code to fill the array with 10 unique values from my list. Here's my code now: $bands = "Bloc Party, Arcade Fire, DFA 1979, Klaxons, Metric, Blur, Small Faces, Smiths, Stripes, Charlatans, MGMT, Strokes"; $bands = explode(", ",$bands); $amountofbands = count($bands); $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; $no[] = $bands[rand(0, $amountofbands)]; array_unique($no); while(count($no) != 10){ $no[] = $bands[rand(0, $amountofbands)]; $no = array_unique($no); } print_r($no); This gives me results that sometimes are blank, and there are also duplicates. How can i fix it!??!?! :facewall: Thank you! Snooble
-
Hey! I'm trying to work out the sql used to create a topic in phpBB. I need to create a topic everytime an upload takes place on the server. I know where to put the code, but I don't know what code I need to use. Hope that makes a sense I'm a little dazed with all this coding! Snoobs
-
thanks so much maq. I'll work out the formatting! I understand now. Thanks!!!! Snoobs
-
I have looked... but it doesn't completey tell me... cause in my database i have: 1228745009 What can i do with that? can you give me a wonderful prod please!? Snoobs
-
so i've a 10 int field. And it's saving time(). How can i output it. Format needs to be 24:00 DD/MM/YYYY Thanks
-
When I create a user in my database I want to record the date and time the record was made. Using PHPMYADMIN what type would the field be? and using php what would i put in the "INSERT" sql statement? Thanks Snooble
-
as i said.. that uploads the file in "/includes/uploads/FILENAME.EXT" i need to put the directory back one first! Thanks though Snoobs
-
Hey. Here's the part of the code I'm having trouble with. The php file is ran from /includes/check.php I want the uploaded file to be moved to /uploads/FILENAME.EXT At the moment is goes to: /includes/uploads/FILENAME.EXT $newname = dirname(__FILE__).'../uploads/'.$filename; Thanks Snoobs
-
directory transversal or something i believe. "../" Anyway. Thought you'd all know, but this was a bug in an earlier version of PHP. I updated my WAMP and now it sends the whole filename, so i just edit it as appropriate! Thanks people! Snoobs
-
if it helps anyone... was a problem with the version of PHP i've got... just downloaded the newest WAMP and it works fine... now i get the full name sent from the upload form. of which i can use str_replace to limit chars. Thanks Snoobs
-
That worked perfectly! Yeah I need to restrict the input! Anyway I can do this? Here's my upload form: <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="checkupload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="104857600" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="uploaded_file" type="file" /> <input type="submit" value="Send File" /> </form> Here's the checkupload.php: <?php //check that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //check if the file is JPEG image and it's size is less than 350Kb $name = basename($_FILES['uploaded_file']['name']); $filename = str_replace("'","",$name); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "mp3") && ($_FILES["uploaded_file"]["type"] == "audio/mpeg") && ($_FILES["uploaded_file"]["size"] < 104857600)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/uploads/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place 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 ".$filename." already exists".$_FILES['uploaded_file']['name'].""; } } else { echo "Error: Only .mp3 songs under 100MB are accepted for upload ".basename($_FILES['uploaded_file']['name']).""; } } else { echo "Error: No file uploaded"; } ?> Thanks Scott! Snoobs
-
Hey, I made an upload form in PHP. Uploaded a file with the name "Boys Don't Cry" the filename on my FTP is now "Boys Don/'t Cry". And it won't let me delete or rename it. Error 550? How can i delete it? Snooble
-
MadTechie : I do not understand what you mean.. Refer to the "checkupload.php" form I uploaded! That uploads the file to my server. Or am I confused? Thanks Snoobs
-
What I'm saying is that the file's name that gets sent from: <form enctype="multipart/form-data" action="checkupload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="104857600" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="uploaded_file" type="file" /> <input type="submit" value="Send File" /> </form> Isn't the full title! I need it to be sent as a full title. How can I get the full filename sent to checkupload.php? Because then i can strip the invalid characters before upload. Thanks Snoobs
-
right so after reading the artical. I've changed the checking process... Now looks like this!: <?php //Сheck that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $name = basename($_FILES['uploaded_file']['name']); $filename = str_replace("'","",$name); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "mp3") && ($_FILES["uploaded_file"]["type"] == "audio/mpeg") && ($_FILES["uploaded_file"]["size"] < 104857600)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/uploads/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place 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 ".$filename." already exists".$_FILES['uploaded_file']['name'].""; } } else { echo "Error: Only .mp3 songs under 100MB are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> BUT! I'm still getting issues with the filename! It still only displays AFTER the apostrophe. I tried echoing out $_FILES['uploaded_file']['name']. And i get "s Game.mp3"! PLEASE HELP! Snoobs
-
ok... how can i validate it? and how would i rename it? I want it to be named when it's downloaded though... ideas? Thanks, Snooble
-
Why would you not allow spaces? should i strip everything harmful.. such as <>-'";:#[]{} etc. just leave _? plus, would the file be uploaded before the page goes to checkupload.php? or is it safe to have the error checking on the checkupload.php page? Thanks people ! Snoobs
-
How can i strip out the apostrophes? thank you Snoobs
-
Hey, I've a quick question.. here's my upload form: <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="checkupload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="104857600" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> And heres the checkupload.php: <?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = 'uploads/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); echo '<pre>'; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { $size = $_FILES['userfile']['size']/ 1024 / 1024; $size = round($size, 2); echo "Successful Upload.\n $size MB"; } else { echo "Possible file upload attack!\n"; } echo 'Here is some more debugging info:'; print_r($_FILES); print "</pre>"; ?> When i try to upload a file called "Snooble's Game.mp3" The saved file is named "s Game.mp3" So i need to escape the ' 's? how!?!? Thanks Snoobs
-
Right, little bit of exploring, I edited the php.ini file that was in the WAMP directory.. After right clicking on the tray icon and going to config files, the one there wasn't edited... editing that stopped the error. Apologies for wasting time, hope it helps someone else! Thank you! Snoobs
-
yup restarted all services.. any other suggestions?
-
[error] => 1 Supposably means "The uploaded file exceeds the upload_max_filesize directive in php.ini." I've edited it in my php.ini! Running on WAMP. What else causes the error? Snoobs
-
thank you.. SOLVED
-
So i alter the database? what type? and i need it to be DD-MM-YYYY. Snoobs
-
[SOLVED] Problem - Converting Bytes to mb! move_uploaded_file!
Snooble replied to Snooble's topic in PHP Coding Help
thank you very much SOLVED