Hi im new here, and id like to start off with an urgent question of mine, which bothers me since a while.
What im trying to do is, to write a text in a normal form textfield, send this to another page where the previously written text is put into a variable and then inserted into my before created database. later all this information should be displayed on another website.
The code looks like this:
// FORM CODE
<form action="insert_db_home.php" method="post">
<br />
<br />
<table width="600" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="160" height="25" align="left" valign="top" scope="col">Your Text: </td>
<th colspan="2" rowspan="2" align="left" valign="top" scope="col"><textarea name="written" rows="7" cols="45"></textarea></th>
</tr> <!-- WRITTEN -->
<tr>
<td width="160" rowspan="2" align="left" valign="top" scope="col"> </td>
</tr>
<tr>
<th width="67" height="25" align="left" valign="top" scope="col"><input type="submit" name="submit" value="Submit" /></th>
<th width="367" align="left" valign="top" scope="col"><input type="reset" name="reset" value=" Reset " /></th>
</tr>
</table>
</form>
which is indeed not that complex. then ill send all this to "insert_db_home.php". the code looks like the following:
<?php
// FETCH INFORMATION FROM upload.php
$written = $_REQUEST['written'];
// ESTABLISH CONNECTION WITH mySQL SERVER
mysql_connect("localhost", "xxxxxx", "xxxxxx") || die(mysql_error());
mysql_select_db("35345-0") || die(mysql_error());
//
mysql_query("INSERT INTO home
(text) VALUES("$written") ")
|| die(mysql_error());
?>
this should insert my stuff ive written in the form into the db "home". yet ill either get the error message "Unknown column 'test' in 'field list'" by entering simply the word "test" in the form or when written more something like "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 'this test)' at line 2".
at last all this should be output (as input before) through this code:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "xxxxxx", "xxxxxx") or die(mysql_error());
mysql_select_db("35345-0") or die(mysql_error());
$query = "SELECT * FROM home";
$result = mysql_query($query) || die(mysql_error());
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo $row['text'];
?>
if anybody could help me out id be so thankful. it bugs me since a while and im really clueless.
i removed the username / password for accessing the db server though. i have those and they are correct.
cheers