Jump to content

$Three3

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by $Three3

  1. Hey thanks for the reply. Yes, that will sort of work, but it does not always work. Is there a better solution other than the HTTP_REFERER?
  2. Hi, I have a slight problem that I have come across when coding for one of my sites. I need to know whether or not a user is coming from a specific address. For example: In order for a user to complete registration for the site, they must come from this url: https://www.somesite.com/cgi/secure?87584 Is there anyway of detecting where a user is coming from? I am almost done with my site but I have been stuck on this for a few days now. Any help is greatly appreciated and thanks in advanced for the help also.
  3. Hi everyone, I am currently working on a site of mine and I have seemed to run into a problem. I have all of my scripts done and working except for the registration script. I have completed the registration script but there is one thing missing on it. I want the user to have to pay the signup fee during the registartion process. My question is, is there any simple or free prebuilt package? If so that would be great and thanks in advandce for the replies. I have searched google but have not found rally what I am looking for. Here is my registration html form: <fieldset><legend>Please fill out the form below to enroll into Lincoln Academy</legend><form action="register2.php" method="post"> <p>First Name: <input name="fname" type="text" size="30" maxlength="26" /></p> <p>Last Name: <input name="lname" type="text" size="30" maxlength="26" /></p> <p>Email: <input name="email" type="text" size="30" maxlength="30" /></p> <p>Cofirm Email: <input name="email2" type="text" size="30" maxlength="16" /></p> <p>Phone: <input name="phone" type="text" size="30" maxlength="16" /><font size="2">(fomrat: 7135620271)</font></p> <p>Address: <input name="address" type="text" size="30" maxlength="60" /></p> <p>City: <input name="city" type="text" size="30" maxlength="60" /></p> <p>State: <select name="state" size="1"> <option value="AK">AK</option> <option value="AL">AL</option> <option value="AR">AR</option> <option value="AZ">AZ</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DC">DC</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="IA">IA</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="MA">MA</option> <option value="MD">MD</option> <option value="ME">ME</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MO">MO</option> <option value="MS">MS</option> <option value="MT">MT</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="NE">NE</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NV">NV</option> <option value="NY">NY</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VA">VA</option> <option value="VT">VT</option> <option value="WA">WA</option> <option value="WI">WI</option> <option value="WV">WV</option> <option value="WY">WY</option> </select></p> <p>ZIP Code: <input name="zip" type="text" size="30" maxlength="16" /></p> <p>Date of Birth: <select name="month"> <option value="1">January <option value="2">February <option value="3">March <option value="4">April <option value="5">May <option value="6">June <option value="7">July <option value="8">August <option value="9">September <option value="10">October <option value="11">November <option value="12">December </select> <select name="day"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 <option value="6">6 <option value="7">7 <option value="8">8 <option value="9">9 <option value="10">10 <option value="11">11 <option value="12">12 <option value="13">13 <option value="14">14 <option value="15">15 <option value="16">16 <option value="17">17 <option value="18">18 <option value="19">19 <option value="20">20 <option value="21">21 <option value="22">22 <option value="23">23 <option value="24">24 <option value="25">25 <option value="26">26 <option value="27">27 <option value="28">28 <option value="29">29 <option value="30">30 <option value="31">31 </select> <select name="year"> <option value="2002">1995 <option value="2003">2003 <option value="2004">2004 <option value="2005">2005 </select> <p>Password: <input name="password1" type="password" size="30" maxlength="16" /></p> <p>Cofirm Password: <input name="password2" type="password" size="30" maxlength="16" /></p> <p><input name="submit" type="submit" value="Enroll" /> <input name="reset" type="reset" value="Reset" /></p> <input name="submitted" type="hidden" value="true" /> </form>
  4. You most likely use a for loop or a foreach loop depending if you're dealing with an array or not. You might also want to heck out the substr() function, the is_file() function, is_dir() function, scandir() function. That should get you started.
  5. Never mind figured it out. When updating the database I was forgetting to apply the SHA1 function to the new password. Works great now.
  6. Awesome thanks a lot man. That worked perfectly. Now I have one more problem though. When this page loads you get the html form. When I am testing it the first time for example with the following values: First Name: John Last Name: Smith Email: jsmith@exmple.com Current Password: 1234 New Password: 123456 Confirm New: 123456 Everything works perfectly and I get the message saying everything has worked successfully. But when I put the exact same values in again but just change the passwords around like: First Name: John Last Name: Smith Email: jsmith@exmple.com Current Password: 123456 New Password: 1234 Confirm New: 1234 It gives me an error saying "There was an error with the update. Please try again." Any help on this is greatly appreciated. Here is the PHP code again: <!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=UTF-8" /> <title>Update Your Information</title> </head> <body> <?php //Check to see if form has been submitted if (isset($_POST['submitted'])) { //Connect to the database if (!$dbc = mysqli_connect('localhost', 'root', 'Sophia211', 'sitename')) { echo '<p><font color ="FF0000">There was an error connection to the database. Please contact the system adminastrator.</font></p>' ; } //Intialize errors array $errors = array() ; //Validate all information received if (empty($_POST['first_name'])) { $errors[] = 'You must enter a first name.' ; } else { $fn = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['first_name']))) ; } if (empty($_POST['last_name'])) { $errors[] = 'You must enter a last name.' ; } else { $ln = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['last_name']))) ; } if (empty($_POST['email'])) { $errors[] = 'You must enter an email.' ; } else { $email = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['email']))) ; } if (empty($_POST['current_password'])) { $errors[] = 'You must enter your current password.' ; } else { $current_password = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['current_password']))) ; } if (!empty($_POST['pass1'])) { if ($_POST['pass1'] != $_POST['pass2']) { $errors[] = 'Your new password does not match the confirm new password. Please try again.' ; } else { $pass = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['pass1']))) ; } } else { $errors[] = 'You must enter a new password.' ; } //Check to see if there were any errors if (empty($errors)) { //Create the query for getting the user_id $query = "SELECT user_id FROM users WHERE email = '$email' AND pass = SHA1('$current_password')" ; $result = mysqli_query($dbc, $query) ; if ($result) { $row = mysqli_fetch_array($result, MYSQLI_NUM) ; //Create the UPDATE query $query = "UPDATE users SET first_name = '$fn', last_name = '$ln', email = '$email', pass = '$pass' WHERE user_id = '$row[0]' LIMIT 1" ; $result = mysqli_query($dbc, $query) ; if (mysqli_affected_rows($dbc) == 1) { //The users information has succesfully been updated echo '<p>Thank You! You have successfully updated your personal information.</p>' ; } else { echo '<p><font color ="FF0000">There was an error with the update. Please try again.</font></p>' ; } } else { echo '<p><font color ="FF0000">There was an error validating your information. Please try again.</font></p>' ; } } else { //There were errors with the validation checks echo '<p><font color ="FF0000"><b>The following errors have occurred:</b></font></p>' ; foreach ($errors as $message) { echo "- <b>$message</b><br />" ; } } } //End of IF SUBMITTED //Display the form echo '<form action="update2.php" method="post"> <p>First Name: <input name="first_name" type="text" size="20" maxlength="20" /></p> <p>Last Name: <input name="last_name" type="text" size="20" maxlength="20" /></p> <p>Email: <input name="email" type="text" size="30" maxlength="80" /></p> <p>Current Password: <input name="current_password" type="password" size="20" maxlength="20" /></p> <p>New Password: <input name="pass1" type="password" size="20" maxlength="20" /></p> <p>Confirm New Password: <input name="pass2" type="password" size="20" maxlength="20" /></p> <p><input name="submit" type="submit" value="Update" /></p> <input name="submitted" type="hidden" value="true" /> </form>' ; ?> </body> </html>
  7. Hey I am stuck on this code. I cannot seem to figure out why this is not working. I have been on it for a couple of hours now and I just need a pair of fresh eyes to look at this. Here is the code: <!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=UTF-8" /> <title>Update Your Information</title> </head> <body> <?php //Check to see if form has been submitted if (isset($_POST['submiited'])) { //Intialize errors array $errors = array() ; //Validate all information received if (empty($_POST['first_name'])) { $errors[] = '<p>You must enter a first name.</p>' ; } else { $fn = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['first_name']))) ; } if (empty($_POST['last_name'])) { $errors[] = '<p>You must enter a last name.</p>' ; } else { $ln = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['last_name']))) ; } if (empty($_POST['email'])) { $errors[] = '<p>You must enter an email.</p>' ; } else { $email = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['email']))) ; } if (empty($_POST['current_password'])) { $errors[] = '<p>You must enter your current password.</p>' ; } else { $current_password = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['current_password']))) ; } if (!empty($_POST['pass1'])) { if ($_POST['pass1'] != $_POST['pass2']) { $errors[] = '<p>Your new password does not match the confirm new password. Please try again.</p>' ; } else { $pass = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['pass1']))) ; } } else { $errors[] = '<p>You must enter a new password.</p>' ; } //Check to see if there were any errors if (empty($errors)) { //Connect to the database if ($dbc = mysqli_connect('localhost', 'root', 'Sophia211', 'sitename')) { //Create the query for getting the user_id $query = "SELECT user_id FROM users WHERE email = '$email' AND pass = SHA1('$current_password')" ; $result = mysqli_query($dbc, $query) ; if ($result) { $row = mysqli_fetch_array($result, MYSQLI_NUM) ; //Create the UPDATE query $query = "UPDATE users SET first_name = '$fn', last_name = '$ln', email = '$email', pass = '$pass' WHERE user_id = '$row[0]' LIMIT 1" ; $result = mysqli_query($dbc, $query) ; if (mysqli_affected_rows($dbc) == 1) { //The users information has succesfully been updated echo '<p>Thank You! You have successfully updated your personal information.</p>' ; } else { echo '<p><font color ="FF0000">There was an error with the update. Please try again.</font></p>' ; } } else { echo '<p><font color ="FF0000">There was an error validating your information. Please try again.</font></p>' ; } } else { echo '<p><font color ="FF0000">There was an error connection to the database. Please contact the system adminastrator.</font></p>' ; } } else { //There were errors with the validation checks echo '<p><font color ="FF0000">The following errors have occurred:</font></p><br />' ; foreach ($errors as $message) { echo '-<b> $message</b><br />' ; } } } //End of IF SUBMITTED //Display the form echo '<form action="update2.php" method="post"> <p>First Name: <input name="first_name" type="text" size="20" maxlength="20" /></p> <p>Last Name: <input name="last_name" type="text" size="20" maxlength="20" /></p> <p>Email: <input name="email" type="text" size="30" maxlength="80" /></p> <p>Current Password: <input name="current_password" type="password" size="20" maxlength="20" /></p> <p>New Password: <input name="pass1" type="password" size="20" maxlength="20" /></p> <p>Confrim New Password: <input name="pass2" type="password" size="20" maxlength="20" /></p> <p><input name="submit" type="submit" value="Update" /></p> <input name="submitted" type="hidden" value="true" /> </form>' ; ?> </body> </html> When I click on submit it gives me no errors whatsoever and displays the form again. If I click on the submit button with no information in the text boxes it is not giving me any errors that it is supposed to be. I have made plenty of these kind of scripts before but I have no idea why this one is not working. I really appreciate the help on this. Thanks in advance for the help.
  8. Ohhh. So this function only works with SELECT statements? Thanks a lot for the help.
  9. Hey, I have a script that will update a users information through a html form and then update it in the database. Everything is working perfectly except for an error I keep getting which is: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/three/public_html/edit_user.php on line 60 The update of the database still works, but this error keeps showing up. I have googled it and tried everything I could think of but I have had no luck yet. Here is my php code: <?php //Set the page title $page_title = 'Update User' ; //Include the header files include ('includes/header.html') ; //Validate that id's are correct // Check for a valid user ID, through GET or POST: if ((isset($_GET['id'])) && (is_numeric($_GET['id']))) { // From view_users.php $id = $_GET['id'] ; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { // Form submission. $id = $_POST['id'] ; } else { // No valid ID, kill the script. echo '<p class="error">This page has been accessed in error.</p>'; include ('includes/footer.html'); exit(); } //Connect to the database require_once ('../mysqli_connect.php') ; //Check to see if the form has been submitted if (isset($_POST['submitted'])) { //Intialize errors array $errors = array() ; //Validate that all form input if (empty($_POST['first_name'])) { $errors[] = '<p class="error">You must enter a first name.</p>' ; } else { $fn = mysqli_real_escape_string($dbc, trim($_POST['first_name'])) ; } if (empty($_POST['last_name'])) { $errors[] = '<p class="error">You must enter a last name.</p>' ; } else { $ln = mysqli_real_escape_string($dbc, trim($_POST['last_name'])) ; } if (empty($_POST['email'])) { $errors[] = '<p class="error">You must enter an email address.</p>' ; } else { $email = mysqli_real_escape_string($dbc, trim($_POST['email'])) ; } //Check to see if there were any errors if (empty($errors)) { //Create the query $query = "SELECT user_id FROM users WHERE email = '$email' AND user_id != $id" ; $run = mysqli_query($dbc, $query) ; if (mysqli_num_rows($run) == 0) { //Query was succesfull //Update the user with the newest values $query = "UPDATE users SET first_name = '$fn' , last_name = '$ln', email = '$email' WHERE user_id = $id LIMIT 1" ; $run = mysqli_query($dbc, $query) ; if (mysqli_affected_rows($dbc) == 1) { //Query was succesful //Print out success message $fetch = mysqli_fetch_array($run, MYSQLI_ASSOC) ; echo "<p>Your update was succesful on the user:<b> " . $fetch['first_name'] . " " . $fetch['last_name'] . "</b>.</p>" ; include ('includes/footer.html') ; mysqli_close($dbc) ; exit(); } else { echo '<p class="error">There was a system error. Please try again.</p>' ; } } else { echo '<p class="error">We are sorry, but the email <b>' . $fetch['email'] . '</b> already exists in our database. Please choose a different email.</p>' ; } } else { //Print out the error messages foreach ($errors as $message) { echo '<p class="error">The following errors have occurred:<br /></p>' ; echo "- $message" ; } } } //Always show the form $q = "SELECT first_name, last_name, email FROM users WHERE user_id=$id" ; $r = mysqli_query($dbc, $q) ; if (mysqli_num_rows($r) == 1) { $row = mysqli_fetch_array($r, MYSQLI_NUM) ; //Display the form echo '<form action="edit_user.php" method="post"> <p>First Name: <input type="text" name="first_name" size="15" maxlength="15" value="' . $row[0] . '"></p> <p>Last Name: <input type="text" name="last_name" size="15" maxlength="30" value="' . $row[1] . '"></p> <p>Email Address: <input type="text" name="email" size="20" maxlength="40" value="' . $row[2] . '"> </p> <p><input type="submit" name="submit" value="Update"></p> <input type="hidden" name="submitted" value="TRUE"> <input type="hidden" name="id" value="' . $id . '"> </form> ' ; } else { echo '<p>You have accessed this page in error(2).</p>' ; //Not a valid user } include ('includes/footer.html') ; mysqli_close($dbc) ; ?> AND HERE IS LINES 49-64 WHERE THE ERROR IS MOST LIKELY OCCURRING: //Create the query $query = "SELECT user_id FROM users WHERE email = '$email' AND user_id != $id" ; $run = mysqli_query($dbc, $query) ; if (mysqli_num_rows($run) == 0) { //Query was succesfull //Update the user with the newest values $query = "UPDATE users SET first_name = '$fn' , last_name = '$ln', email = '$email' WHERE user_id = $id LIMIT 1" ; $run = mysqli_query($dbc, $query) ; if (mysqli_affected_rows($dbc) == 1) { //Query was succesful //Print out success message $fetch = mysqli_fetch_array($run, MYSQLI_ASSOC ; echo "<p>Your update was succesful on the user:<b> " . $fetch['first_name'] . " " . $fetch['last_name'] . "</b>.</p>" ; include ('includes/footer.html') ; mysqli_close($dbc) ; exit(); Thanks in advance for the help.
  10. How big is the file you are trying to upload? Also, did you edit the original php.ini file on your server of make a new one?
  11. Okay, it really does not seem to be a code problem to me. It might be a few other things. Try these and see if it helps: 1.) The folder "uploads" might need the permissions to be changed. Try setting them 0755 or 0777. 2.) if you can, depending on your privileges with your server, try putting the uploads directory outside of the web root. So instead of the variable $tagert_path = 'uploads/' it would be written like this: $target_path = '../uploads/' 3.) If you cannot change the path of the uploads directory, try add a forward slash in front of the directory like this: $target_path = '/uploads/' Try those and hopefully one of those work for you.
  12. You could try this: ini_set('display_errors', 1); You could put that at the beginning of your PHP scripts and this will turn error reporting on. The only problem with this solution is that if there are any syntactical errors in your script, your server still will not display any errors. The best solution is to edit your PHP.ini file and turn display_errors On. You could also try this: error_reporting(E_ALL); ini_set('display_errors', 1); This might be better than the first solution.
  13. Have you tried adding the MAX_FILE_SIZE option in the HTML part of your code? If not, then you could try this: <input type="hidden" name="MAX_FILE_SIZE" value="512000" /> The MAX_FILE_SIZE value is the maxium number of bytes you want to be allowed while uploading a file. So 512,000 bytes is 500KB. So if you wanted it to be equal to 50MB you would need to change that value to 52428800. So you whole html code should look like this: <form enctype="multipart/form-data" action="logosProcessor.php" method="POST"> <p> <input type="hidden" name="MAX_FILE_SIZE" value="52428800" /> <input name="newLogoName" type="text" size="25" value="<?php echo $_POST['logoListDropDown']; ?>"> <input type='submit' name="updateLogoName" value="Update Logo Name"/> <input type='submit' name="deleteLogo" value="Delete Logo"/> <input type="hidden" name="oldLogoName" size="25" value="<?php echo $_POST['logoListDropDown']; ?>"> </p> <p> <input type="file" name="myfile"> <input name="uploadLogo" type='submit' value="upload" > </p> </form>
  14. You can use the ob_start() function and the ob_flush() function: http://php.net/manual/en/function.ob-start.php http://www.php.net/manual/en/function.ob-flush.php Then you will be able to send the code: header('Location: thank_you.php') exit();
  15. Just add the addslashes function to it. http://php.net/manual/en/function.addslashes.php
  16. Okay, the code above should start with <?php session_start(); ?> before you assign any values to the $_SESSION array. Once you have stored the value such as the email address to the $_SESSION array, you can then access this value on any other page like so: <?php session_start() ; echo $_SESSION['emailses'] ; ?>
  17. PHP: <?php session_start(); include('dbconfig.php'); $date = date('g:iA M d, Y'); $target_path1 = "portimages/"; $target_path1 = $target_path1 . basename( $_FILES['uploadedfile']['name']); $target_path2 = "portimages/"; $target_path2 = $target_path2 . basename( $_FILES['uploadedfile2']['name']); if($_SESSION['level'] == 'admin') { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path) && move_uploaded_file($_FILES['uploadedfile2']['tmp_name'], $target_path2)) { mysql_query('INSERT INTO `portfolio images` (path, path2, date, title, description) VALUES ("/portimages/'.$_FILES['uploadedfile']['name'].'","/portimages/'.$_FILES['uploadedfile2']['name'].'","'.$date.'","'.$_POST['title'].'","'.$_POST['description'].'")') or die (mysql_error()); echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; header("Location: ".$_SERVER['HTTP_REFERER']); } else { echo "There was an error uploading the file, please try again!"; } } else { echo'please login with an admin account'; } ?> ERROR MESSAGE: Warning: move_uploaded_file() [function.move-uploaded-file]: Filename cannot be empty in /home4/annarbo1/public_html/svidler/uploadimage.php on line 13 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpl3c23c' to '' in /home4/annarbo1/public_html/svidler/uploadimage.php on line 13 There was an error uploading the file, please try again! What's wrong with it? Hey the only thing I see wrong with this code is that on this line here: if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path) Which is the first if (move_uploaded_file) check, the variable $target_path should be $target_path1. All you did was forget the 1 on the end.
  18. That is very likely to be true. Just learn some basics of OOP to understand terms like inheritance/method/property so that JavaScript syntax doesn't baffle you. Thanks again guys. I will definitely look into both of them and do what you all have said.
  19. Misnomer. Virtually everything in JavaScript is an object. The difference is that JavaScript uses prototypal inheritance rather than the traditional parent-child form of inheritance most popular languages use. For the OP - OOP is a programming methodology, a way of programming that many (including myself) feel make it easier to write flexible, maintainable code. You shouldn't look at it as a decision between OOP and JavaScript/Ajax. One is a way of programming, the others are technologies used in programming (Ajax is a bit of both, if you want to get pedantic). And, if you want to be taken seriously as a developer, you'll need to learn both. Hey thanks a lot for the reply. Ok I understand now that I should go ahead and learn both which in the end will be the most beneficial. One more question though. Which one should I try learning first? Thanks again
  20. No, you will not be able to do anything different. What you will be able to do is write code that is more efficient, easier to extend, easier to fit into other projects, easier to modify, used to create more complex and scalable systems. OOP is a concept. It is not specific to PHP. It is a style of programming so it does not matter what language you wish to use it with. The question you should ask is, would my projects be better off using OOP techniques, are they on the scale that would suit OOP. OOP practices take more time to implement, and you're not going to get it perfect all the time, trust me. If you're creating simple websites that may have a blog, some pictures, some comments, etc then a script written in a procedural fashion is more suited. It's quick to impement. On the other hand if you are creating the next facebook... (meaning a larger system that you will be modifying and adding functionality to) Learn Javascript if you think it will benefit your projects. I cant say if it is more beneficial than anything else, unless it is required for a job you are going for, or you need it for a project you are working on. When you say more beneficial, more benificial for what? Hey thanks for that reply that really cleared some things up for me. What I mean by beneficial is for mostly web programming. So should I learn OOP or somethng like JavaScript or Ajax? Thanks again for that helpful reply.
  21. Is learning and knowing about Object-Oriented Programming PHP worth my time in the sense that I will be able to do a lot more things that I cannot already do with PHP and SQL? I am just wondering because I am thinking about reading a book on just Object-Oriented Programming PHP and I want to know if it will be really beneficial to learn Object-Oriented Programming PHP or would it be more beneficial to learn another language like javascript. Thanks in advance for the advice and help.
  22. Here check out these 2 links. These should solve your problem: http://www.php.net/manual/en/function.move-uploaded-file.php#77661 http://www.php.net/manual/en/function.move-uploaded-file.php#95084
  23. Ok the error is your naming scheme of the file. What your code is doing is it is trying to say that a file is there when it is really not. This line here is your problem: $uploadfile = '/resources/familyties/'.substr($_POST['date'], 0, 2).'_'.substr($_POST['date'], 3, 2).'_'.substr($_POST['date'], 6, 4).'.pdf' ; The reason this is wrong is because the first line of code is naming a file by the current date which is then making a file that does not exists on the server therefore you are getting those dreadful error messages. Try changing your code to this: $uploadfile = "/resources/familyties/{$_FILES['file']['name']}" ; What this does is whatever the name is of the file the person is uploading is what the name will be on the server. Also, you were trying to name the file being uploaded with the extension of a ".pdf" but if the file the person is uploading is not a true ".pdf" it will not matter if you append the ".pdf" extension to the file being uploaded. If you want to only allow pdf files to be uploaded you should specify the mime type that is allowed with the file upload. For example: if ($_FILES['file']['type'] != "application/pdf") { echo "<p>Your file could not be uploaded because: You can only upload PDF's.</p>" ; } Also, if you want to rename the file being uploaded, you might want to look at the rename function: http://php.net/manual/en/function.rename.php
  24. Hey everyone, I am new to MySQL and I have been having a hard time understanding the GROUP BY clause. I have not been able to find a basic example that will let me grasp what it actually does. I am currently reading a MySQL book and here is the code from the book that uses the GROUP BY clause: SELECT state, COUNT(*) AS count FROM president GROUP BY state ORDER BY count DESC; And here is the output from that query: +-------+-------+ | state | count | +-------+-------+ | VA | 8 | | OH | 7 | | MA | 4 | | NY | 4 | | NC | 2 | | VT | 2 | | TX | 2 | | SC | 1 | | NH | 1 | | PA | 1 | | KY | 1 | | NJ | 1 | | IA | 1 | | MO | 1 | | CA | 1 | | NE | 1 | | GA | 1 | | IL | 1 | | AR | 1 | | CT | 1 | +-------+-------+ Any help explaining what the GROUP BY clause actually does and how it works would be great. I understand the rest of the code except for the GROUP BY part. Thanks in advance for the help.
×
×
  • 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.