Mr Chris Posted April 11, 2006 Share Posted April 11, 2006 Hi Guys,Trying to ‘tidy-up’ things on my site and trying to use include php files. So I have this form, which posts data from a website page to a database which has include files:[code]<?php include 'librarys/config.php';include 'librarys/opendb.php'; // POST variables$section = $_POST['section'];$added_by = $_POST['added_by'];$headline = $_POST['headline'];$byline_name = $_POST['byline_name'];$appeared = $_POST['appeared'];$opening = $_POST['opening'];$body_text = $_POST['body_text'];$pic_caption = $_POST['pic_caption'];$pic_ref = $_POST['pic_ref'];$notes = $_POST['notes'];// If submit is hit then insert data into databaseif(isset($_POST['upload'])){ $query = "INSERT INTO cms_stories ( section,added_by,headline,byline_name,appeared,opening,body_text,pic_caption,pic_ref,notes) VALUES ('$section','$added_by','$headline','$byline_name','$appeared','$opening','$body_text','$pic_caption','$pic_ref','$notes')"; $msg = "A new story has been added to the database - Please Click <a href=\"menu.php\">Here</a> to return to the main menu";} ?>[/code][b]Config file[/b][code]<?php// db properties$dbhost = 'localhost';$dbuser = '**********'; $dbpass = '*********'; $dbname = '*********'?>[/code][b]Opendb file[/b][code]<?php$conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ($dbname);?>[/code]But since I created the opendb file and config file holding the password data and connection data my form no longer posts to the mysql database? There are no mysql errors, so can anyone please see why it does not post to the db table?ThanksChris Quote Link to comment Share on other sites More sharing options...
trq Posted April 11, 2006 Share Posted April 11, 2006 You never run the query. Try using mysql_query(). Quote Link to comment Share on other sites More sharing options...
arifsor Posted April 11, 2006 Share Posted April 11, 2006 Hi You missed to call mysql_query() fuction after creating the query[code]mysql_query($query);[/code] Quote Link to comment 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.