Jump to content

[SOLVED] Basic MySQL help requested!


Guernica

Recommended Posts

Hi, I am new to php and mySQL and I tried reading some tutorials and stuff on some places such as w3schools. I created a basic file upload form which when successful displays your file size, type, and a download link for the file.

 

My index.php has this for the form:

 

  <form name="uploaded" id="uploaded" method="post" action="upload.php" enctype="multipart/form-data" onsubmit="document.ul.u.value='Please wait ...';document.ul.u.disabled=true;return checkPHP();">
  <input type="hidden" name="maxsize" value="26214400" />
  <input type="hidden" name="uploaded_type" />
  <input type="hidden" name="fileid" />
    <div id="files">
      <label><b>Title:</b> </label> <input class="input" type="text" size="72" name="title" id="title"> <br/>
      <textarea name="description" id="description" rows="3" cols="74" value="Description here...">Description</textarea> <br/>
      <input class="input" type="file" size="64" name="uploaded" id="filenamez"><br/>
      <input type="submit" name="u" value="Upload File!"></div></form>

 

Then on upload.php I have this in part of my php tags:

 

mysql_connect("localhost", "**db_username**", "**db_pass**") or die(mysql_error());
echo "<br />Information sent!";
mysql_select_db("**db_name**") or die(mysql_error());
echo "<br />Updated!";

INSERT INTO uploaded (title, description)
VALUES ('$title', '$description')

 

It connects to the database file, because I tried it without the INSERT blahblah...

 

When I try and send the $title and $description it gives me "Unexpected T_STING" error. Please help!

I am really new to this lol.

Link to comment
Share on other sites

A few bits missing

 

mysql_select_db("**db_name**") or die(mysql_error());
$query = "INSERT INTO uploaded (title, description) VALUES ('$title', '$description')"; // define query string
$result = mysql_query($query) or die(mysql_error()); // execute query
echo "<br />Updated!";

 

edit: That's the stuff missing from upload.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.