chuddyuk Posted March 14, 2006 Share Posted March 14, 2006 I have a form which submits info into a database, it is very simple at the moment once i have solved this problem i will add the rest of my feilds. It submits, but on the variable name like it will show $title an $news in the database, i know its somethin v simple but cant figure it out please help, here is the page::[code]<? if(isset($_GET['commented'])){ // Tell the user it has been submitted (optional) echo('Your comment has been posted.');include "common.php";// Set global variables to easier names$titles = $_GET['title']; $new = $_GET['news']; // Connect to Mysql, select the correct database, and run teh query which adds the data gathered from the form into the databasemysql_connect($dbhost,$dbuser,$dbpasswd) or die(mysql_error());mysql_select_db($dbname) or die(mysql_error());$add_all = 'INSERT INTO `news` (`title`, `news`) VALUES (\'$titles\', \'$new\')'; mysql_query($add_all) or die(mysql_error());}else{// If the form has not been submitted, display it!?><form method="get" action="<?php echo $PHP_SELF?>">Title : <input type='text' name='title'><br><br>News : <input type='textarea' name='news'><br><br><input type='hidden' name='commented' value='set'><input name='submit' type='submit' value='Post your comment'></form> <?}?> [/code]Thanks Quote Link to comment https://forums.phpfreaks.com/topic/4914-data-form-info-into-database/ Share on other sites More sharing options...
shocker-z Posted March 14, 2006 Share Posted March 14, 2006 Instead of[code]$add_all = 'INSERT INTO `news` (`title`, `news`) VALUES (\'$titles\', \'$new\')';[/code]use[code]$add_all = "INSERT INTO `news` (`title`, `news`) VALUES ('$titles', '$new')";[/code]And thats it :) Quote Link to comment https://forums.phpfreaks.com/topic/4914-data-form-info-into-database/#findComment-17322 Share on other sites More sharing options...
chuddyuk Posted March 14, 2006 Author Share Posted March 14, 2006 Works a Treat thanks !!!!Knew it was something really simple!!!! Quote Link to comment https://forums.phpfreaks.com/topic/4914-data-form-info-into-database/#findComment-17330 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.