This form is not working.
When I click Save it shows this error.
Quote:
|
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 'add SET (`id`, `code`) VALUES (NULL, 'sdfsd')' at line 1
|
This is the code.
PHP Code:
<form method="post"> <?php // if if(isset($_POST['preview'])) { // show code as html echo $_POST['code']."<br />"; // show save and edit buttons echo "<input type='submit' name='save' id='submit' value='Save' /><input type='submit' name='edit' id='submit' value='Edit code' />"; } else { // if not preview then show form ?> <label>Enter Add Code:</label> <textarea name="code" style="width: 200px; height: 100px;"><?php // if edit then show code in textarea if(isset($_POST['edit'])) { echo $_POST['preview']; } // if not edit ?></textarea> <input type="submit" name="submit" id="submit" value="Save" /> <input type="submit" name="preview" id="submit" value="Preview" /> </form> <?php // check if submited code if(isset($_POST['submit'])) {
/* connect to the database */ // conect to the server $connect = mysql_connect("localhost","db_username","db_password"); // if connected to the server continue if($connect == TRUE) { // Select the database and check if connected if(mysql_select_db("db_name") != TRUE) { // if not connected display error exit("<span style='color: red'>Can't connect to the MySQL database. Please contact the webmaster.</body></html>"); // end if can not connect to database } // if not connected to the server then contiunue } else{ // display error if not connected to the server exit("<span style='color: red'>Can't connect to the MySQL server. Please contact the webmaster.</body></html>"); // end if not connected to the server }
// insert add into database $sql = mysql_query("UPDATE add SET (`id`, `code`) VALUES (NULL, '".$_POST['code']."')") or die (mysql_error());
if($sql = TRUE) { // echo complete msg or divert echo "the code has been updated"; // divert back to this page header('location: forms.php'); } // end complete } // end submit } // end if not preview. ?>
---
More about the form:
Basicly what I need, is a Ad Managment script.
Some things In it:
A form, basicly a textarea where I can insert the code and click update.
When I click Update, on the index it will show the Banner/Advert I have placed.
Like It would connect to a database or something.
Thats all I need, no counters, nothing special, a form thats it.
The first person being able to help me out.
---- - I would create a page in the admin section that displays the current ad with a form below.
- The form would be a big text area that updates the database, the value of the form would come from the database displaying the html code in the text area.
- Once the form is edited and submitted the page would reload displaying the new ad.
- Each ad would require its own page, re-using the original code.
- Maybe create a preview button to make sure you entered the correct code before you update the database.
I will be able to do something in return, if that means, give you FREE hosting with any features you want or designing you a logo.
|