Jump to content


Photo

include files!


  • Please log in to reply
2 replies to this topic

#1 Mr Chris

Mr Chris
  • Members
  • PipPipPip
  • Advanced Member
  • 336 posts

Posted 11 April 2006 - 01:52 PM

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:

<?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 database
if(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";
} 

?>

Config file
<?php
// db properties
$dbhost = 'localhost';
$dbuser = '**********'; 
$dbpass = '*********';    
$dbname = '*********'
?>

Opendb file
<?php
$conn = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($dbname);
?>

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?

Thanks

Chris

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 11 April 2006 - 02:01 PM

You never run the query. Try using mysql_query().

#3 arifsor

arifsor
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts
  • LocationPakistan

Posted 11 April 2006 - 02:10 PM

Hi

You missed to call mysql_query() fuction after creating the query
mysql_query($query);

---------------------------
Power Demand Respect
Arif Sorathia




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users