Everything posted by Endlessline
-
Where to learn PHP?
To point out the obvious, but a great reference once you get your skills off the ground http://www.php.net
-
Check Image size before upload
Good call, that seems to be the only sure fire way of limiting upload size with PHP that i've found is through the config. I'm wondering if there is a less extreme way of doing it but it may be a limitation of PHP.
-
Check Image size before upload
Pat, thanks for your great reply. Your script looks great. I was wondering if you can check the file size before the file is fully uploaded? Your script looks great for working with the uploaded file but I would like to stop the upload if the file is going to be above the upload limit.
-
Check Image size before upload
So my client wants pictures to be uploaded, so awesome. PHP seems to be doing the job very well once the file is in its possession. As I understand it when you upload the file from a HTML form PHP puts the file into temporary memory and then deletes it if you don't call the move_uploaded_file function. All very good, you can check for size, width, height, etc. I'm a bit worried however that even if I set $_FILE['fileName']['size'] to something reasonable (2mb or so) a evil evil user could upload something that was very large and only after the image was put in the temp memory would it be deleted....wasting oh so valuable bandwidth!!!! Obviously javascript will help benevolent users but what about the hackers,spammers,and general delinquents of the internet? Is there a way that I can have PHP check the HTTP header for file size before uploading is completed and abort if the file is too large?
-
CMS For a Photographer
This might be a bit confined for your use but its so easy to use. Might be worth a look http://slideshowpro.com/
-
PHP - Processing an unlimited number of form elements
I must confess, I didn't ready everything but I think i get what you are trying to do. First of all, I would stick in a hidden filed (perhaps dynamic) that will give you your ID for the event like so... <input type="hidden" value="59" name="eventID"> You might want to check out PHP's date() method so that you don't have to manually update your date field Take <td> <select name = "selNumAdultTicketsEventID59"> <option value="0">0 x £39.00</option> <option value="1">1 x £39.00</option> <option value="2">2 x £39.00</option> <option value="3">3 x £39.00</option> </select> </td> And convert it to a for loop to save your tired fingers!... <? echo '<td>'; echo '<select name = "' . $id . '">'; //selNumAdultTicketsEventID59, $id is a variable that you can set rather than having to write it out each time since we know the event id from our hidden field this can be set to adult/child/etc $price = "£39.00"; $maxTickets = 4; for($i = 0; $i <= $maxTickets; $i++){ //$maxTickets is the maximum you can purchase set above echo '<option value="$i">' . $i . ' x £39.00</option>'; //This will print out the box as it appears above } echo '</select>'; echo '</td>' So lets say that you have your hidden input box with your event id, and some other inputs with ADULT TICKETS, CHILD TICKETS, CONC TICKETS They will look like this once posted $_POST['aTickets'] //Adult Tickets $_POST['cTickets'] $_POST['concTickets'] $_POST['eventID'] On the page you are submitting (Make sure you are using method="post") this information to, say submit.php we can get these values into an array like so <?php $orderArray = array(); //Create an array assigned to $orderArray $orderArray[] = $_POST['aTickets']; //Adult Tickets $orderArray[] = $_POST['cTickets']; $orderArray[] = $_POST['concTickets']; $orderArray[] = $_POST['eventID']; //Then try print_r($orderArray); //You should see your values here! ?>
-
Loop mysql results with OOP PHP5
returning the functions value is a good start, depending on how you have your objects setup you would just call that instance of the object and set the returned value from the method to a variable. I think its like this, I'm kinda new to OOP/PHP5. Oh, i'm assuming you've included the necessary class file.. <?php class Value { require('pathToDBobj'); //Edit: this will include the class info you need to call getMemberAndLocationByName() $obj = new DBobj(); //this is the instance that holds your function you created above it is constructed here. //You will need to substitute the name of DBobj with the class name of the class that //holds your method $newName = $obj->getMemberAndLocationByName($name); // I believe this will set $newName to the returned value of your method } ?> I would like to note, I think you may want to restructure your method a bit so that it is not so specific to this task. Instead of getMemberAndLocationByName($name) you could rewrite the function something like getValueAndIDByKey($key) and perhaps restructure the method a bit so that you can reuse it later in other code. Obviously this is an exercise outside the scope of your question and since we are both learning perhaps it's best to stay with one topic at a time. If anyone a bit more advanced in the OOP has any advice I'd love to hear it regarding this matter. Thanks, hope my snippet helps!
-
Scrolly gallery playing mp3 riddle!
Is the component in AS 2.0 or 3.0 ?
-
fonts
Your trying to get a font to render that isn't on a client's browser? I've never done this but had to research it a long time ago (i think i follow your question) you will need to use PHP with the installed font to render the font as an image. Sorry I can't be of more help.
-
Center my CSS menu
Try... ul li {text-align:center} //This will center the list item elements you can also use margin:0 auto; to center stuff post your HTML so we can see how your implementing the CSS/HTML
-
Remove Element From Array
Found this hot off the Google presses, Thanks to xmouse whoever and wherever he/she is. Gracias! Hopefully this will help others with the same problem, simple solution Removing Elements from array
-
Pre loading image directory
What technology are you using? Flash/Actionscript could do this AJAX and probably others
-
Remove Element From Array
I'm trying to remove an element in an array (in PHP) and then reset the index of the array so that... Original array Array[0] => Taco [1] => Burrito [2] => Hot Dog [3] => Lead Pipe I'm trying to create a method that will remove an element using the index as its only param removeFromArray(2); Resulting array Array[0] => Taco [1] => Burrito [2] => Lead Pipe I've tried unset and $array[id] = null but I don't think they are working.... any ideas?
-
How to make Link counters?
Yea, I think PHP would be the way to go with MySQL to record everything. If there is a more lightweight option, i'm all ears, this reply is from the hip. I think you would just need a script that added 1 to a row everytime it was clicked and a script to query the DB for that number to return the counter.
-
I Have Problem With "if"
if ($a<>ereg("^[0-9]") needs to be if ($a<>ereg("^[0-9]")) <--- Extra ) needed, your code spills out and gets an unexpected { b/c its expecting a )
-
Build a betting website
Ideally, you would need an entire team of people to make the site. Doing it by yourself and having the project succeed would be extremely impressive.
-
writing to databases
Thank you o wise ninja Mihai, you have served us both
-
Linkable rotating article display with images and hover?
Yep, you can definitely do it with a number of techniques. A javascript library like jQuery or Mootools is probably your best bet along with CSS as well as PHP. This looks like a component similar to things you'd see on www.rockettheme.com (for Joomla). Depending on your site I might reccomend you look into Joomla as a CMS because you can add things like this in literally a few minutes rather than having to develop it from the ground up (although that way is always more badass)
-
Multiple contacts
Sure, you would need to write a conditional statement to check for where the form would be sent. All your form's input will be in either the $_GET or $_POST array depending on what you set your form method to (i.e. <form method="post" name="myForm" action="page2.php">). Your php would look something like this, we'll assume the radio button is called "rec" page2.php <?php $val = $_POST['rec']; //This is the data from the prior page //You should also filter your data using mysql_real_escape_string() to guard against SQL injections as well as other measures, not really necessary for now though switch($val){ case 'bob': mail('bob@bobmail.com','subject of the message','message'); //php mail command, php.net search mail() break; case 'steve': mail('steve@bobmail.com','subject of the message','message'); break; case 'sara': mail('sara@bobmail.com','subject of the message','message'); break; } ?> There are a number of ways to do this. I use a switch case but you can use a variety of if statements if you feel more comfortable. Alternatively you could wrap this in a function so that it would be dynamic and you don't have to type so much. Anyway. Hope this helps!
-
writing to databases
I think you need to run another query to confirm whats in the DB. MySQL is probably my worst area, hopefully a wiser ninja knows.
-
Can I trust mysql_real_escape_string() ?
Zoli, thanks for you response. I did some digging and it appears we both may need this article. Sounds like it works pretty well but can be fooled... Limitation of mysql_real_escape_string()
-
Can I trust mysql_real_escape_string() ?
The axiom "don't trust any user input" is all important. Can I trust mysql_real_escape_string() ? Is it the all inclusive wonder function that will kill any chance of SQL injection in that data field? I realize that there are other places to get in but for the sake of argument lets assume I have a form with only one field, if I use this function on that field before it is queried can I assume it is safe?
-
array_unshift() doesn't work as planned
that will work, thanks for your response
-
Unrar file with PHP
yea, have to go the admin. thanks though !
-
PHP Tags
good call, my lazy fingers! <?php is better