Jump to content

jvo

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jvo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay, so I've been trying to figure this out for a while. I've rewritten the code and checked for simple syntax error and I still get the same result. There's no error, but it just doesn't do anything. I've put an echo statement in there to test that the parameter has been set, but it obviously hasn't. Can anyone tell me why that is? Here's my code. It's a little primative, but I've not done any fine tuning. I just want to get it to do one thing first. Eventually, I want to have the URLs of the files to be saved to a DB, but as I've not yet gotten this to work, I haven't written it. [code] <html> <head> <title> .::Upload::. </title> </head> <body> <?php if(isset($_POST['upload1'])){    echo "Word Up";    //Upload path (relative to this file)    $uploadDir = "images/";    $path1 = $uploadDir . basename($_FILES['upload1']['name']);       echo "Word Up";    if(move_uploaded_file($_FILES['upload1']['tmp_name'],$path1)){       echo "The file ". basename($_FILES['upload1']['name'])." has been sucessfully uploaded";       }    else{       echo "There was an error with your upload. Please try again.";       }    if(isset($_POST['upload2'])){          $path2 = $uploadDir . basename($_FILES['upload2']['name']);       if(move_uploaded_file($_FILES['upload2']['tmp_name'],$path2)){          echo "The file ". basename($_FILES['upload2']['name'])." has been successfully uploaded";          }       else{          echo "There was an error with your upload. Please try again.";          }       }    if(isset($_POST['upload3'])){          $path3 = $uploadDir . basename($_FILES['upload3']['name']);       if(move_uploaded_file($_FILES['upload3']['tmp_name'], $path3)){          echo "The file ". basename($_FILES['upload3']['name'])." has been successfully uploaded";          }       else{          echo "There was an error with your upload. Please try again.";          }       }    } ?> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="650000"> <font face="arial" pt size="2"> File location: <input type="file" name="upload1"> <br> File location: <input type="file" name="upload2"> <br> File location: <input type="file" name="upload3"> <br> <input type="submit" value="Upload"> </form> </body> </html> [/code] I'm trying to check that the value of atleast the first file has been set with [i]if (isset($_POST['upload1'])) {...[/i] but I'm guessing it's returning false and I don't know why. Can anyone shead some light on this?
  2. jvo

    Broken Code?

    [!--quoteo(post=364165:date=Apr 12 2006, 03:26 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 12 2006, 03:26 PM) [snapback]364165[/snapback][/div][div class=\'quotemain\'][!--quotec--] If nothing is being added to your Database then there is a likely chance you have an error with your Query. To find out change this: [code]mysql_query($query);[/code] to: [code]mysql_query($query) or die("Error: " . mysql_error());[/code] Run you code again this time if there is a problem with your query it'll stop the script and show an error message. if it does return an error, post the full error message here and we'll try to help. [/quote] Hey, thanks so much for the fast reply. I did exactly what you said and here's what I get [i]Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' VALUES ('','johndoe','0000','john@doe.com','John','D[/i] I'm rechecking my code now, but it still looks fine. Any advise?
  3. I am trying to implement a website using PHP and so far it's going rather well. Today I ran upon a bit of a hiccup. I've written some code folloing a tutorial that allows people to enter information to a database and it worked fine for a little while. But now it's broken. On the user end, it looks like it works, but when I actually browse the contents of the database, the information has not been added. I'm relatively new to the PHP/MySQL platform but as I'm not so familiar with the syntax yet, I could very well be over looking something quite simple. Below is the code from the two pages I have. SIGNUP.HTML <html> <head> <title>.:: New User ::. </title></head> <body> <font face="arial" pt size=1> <form action="insert.php" method="post"> Username: <input type="text" name="user"><br> Password: <input type="password" name="password"><br> Confirm Password: <input type="password" name="password"><br> Email: <input type="text" name="email"><br> First Name: <input type="text" name="first"><br> Last Name: <input type="text" name="last"><br> Primary Contact: <input type="text" name="phone"><br> Age: <input type="text" name="age"><br> Gender: <input type="radio" name="gender" value="M">Male <input type="radio" name="gender" value="F">Female<br> <input type="Submit"> </form> </body> </html> INSERT.PHP <?php include("library/dblogin.php"); $user=$_POST['user']; $password=$_POST['password']; $email=$_POST['email']; $first=$_POST['first']; $last=$_POST['last']; $phone=$_POST['phone']; $age=$_POST['age']; $gender=$_POST['gender']; $query = "INSERT INTO users VALUES ('','$user','$password','$email','$first','$last','$phone','$age','$gender','0')"; mysql_query($query); mysql_close(); ?> <html> <head> <title> .:: New User ::. </title> </head> <body> <font face="arial" pt size="1"> <p align="center"> Your account has been successfully created.<br> Thank you for registering. <br> </p> </body> </html> So there it is. Is there any reason why this code shouldn't work? Any insight would be helpful.
×
×
  • 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.