Guernica Posted July 1, 2007 Share Posted July 1, 2007 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 https://forums.phpfreaks.com/topic/57915-solved-basic-mysql-help-requested/ Share on other sites More sharing options...
AndyB Posted July 1, 2007 Share Posted July 1, 2007 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 https://forums.phpfreaks.com/topic/57915-solved-basic-mysql-help-requested/#findComment-286984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.