mysql_query(): supplied argument is not a valid MySQL-Link resource
Below is the the section of the PHP code that I am using to process this form, once the user has logged in:
Code: Select all
<?php
session_start();
error_reporting(E_STRICT);
require_once('required_files.php');
require_once('database_connect.php');
$username = $_SESSION['valid_user'];
$title=$_POST['title'];
$content=$_POST['content'];
$connect = db_connect();
if ($connect)
echo 'works';
else
echo 'Did not connect';
$insert = "insert into posts (post_id, username, title, content, input_time) VALUES ('', '".$username."', '".$title."', '".$content."', CURRENT_TIMESTAMP())";
$con = mysql_query($insert, $connect);
if($con){
echo 'Query good';}
else{
echo error_display();}
?>
Also is the syntax correct for my insert statement? - Why do I have to enclose the variable like this: '".$variable."' - to get them to work? I though they only need to be enclosed within single quotes ('$variable') for the MySQL query?
Thanks so much!