CodeIgniter Forums

Full Version: database trying to connect
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm trying to connect to a database and table and it still not working this is what i did

home.php view
&lt;form name=”web_form” id=”web_form” method=”post” action=”upload_c.php”&gt;
<p><label>Username:</label>&lt;input type=”text” name=”username” id=”username” /&gt;&lt;/p>
<p><label>Subject:</label>&lt;input type=”text” name=”subject” id=”subject” /&gt;&lt;/p>
<p><label>Comment:</label>&lt;input type="text" name="comment" id="comment" /&gt;&lt;/p>
<p><label>File:</label>&lt;input type="file" name="file" size="40" /&gt;&lt;/p>
<p><button type=”submit” value=”Submit”>Submit</button></p>
upload_c.php view
$db=mysql_connect($host, $user_name, $password);
if (mysql_error() > “”) print mysql_error() . “<br>”;
mysql_select_db($database_name, $db);
if (mysql_error() > “”) print mysql_error() . “<br>”;
$username = $_POST["username"];
$subject = $_POST["subject"];
$comment = $_POST["comment"];
$file = $_POST["file"];
$submitdate = date(”Ymd”);
$query = “insert into upload_data (username, subject, comment, file, submitdate) values (’” . $username . “‘, ‘” . $subject . “‘, ” . $comment . “, ‘” . $file . “‘, ‘” . $submitdate . “‘)”;
$result = mysql_query($query);
echo “<h1>Thank you for submitting your details!</h1>”;
home controller
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
public function index()
  $data = array(
               'title' => 'lulzlab - every lulz has a story'
  $this->load->view('template/header', $data);
upload controller
class Upload extends CI_Controller {
public function index()

Does anyone know what i did wrong?,..