Jump to content

include files!


Mr Chris

Recommended Posts

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 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";
}

?>
[/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?

Thanks

Chris
Link to comment
https://forums.phpfreaks.com/topic/7109-include-files/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.