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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.