Script not running properly


Posted on 16th Feb 2014 07:03 pm by admin

Hello Everyone
This is a basic script for posting to a database. I'm not sure why it doesn't work. Can anyone tell me why?

Code: [Select]<?php
Did you know?Explore Trending and Topic pages for more stories like this.
require('config.php');
if(isset($_GET['id']) == TRUE && isset($_GET['td'])==TRUE){
if(is_numeric($_GET['id'])==FALSE || is_numeric($_GET['td'])==FALSE) {
$error = 1;
}
if($error == 1){
header("Location: " . $config_basedir);
}
else{
$validentry = $_GET['id'];
$validtd = $_GET['td'];
}
}
else{
$validentry = 0;
}
if($_POST['submit']) {
$db = mysql_connect($dbhost,$dbuser,$dbpassword);
mysql_select_db($dbdatabase, $db);
if(!$db){
die('FAILED TO OPEN DATABASE:' . mysql_error());
}

$sql = "INSERT INTO todo(id, topic, date, comment)
VALUES (" . $validentry . ", '" . $_POST['topic'] .
"', '" . $_POST['date'] . "', '" . $_POST['comment'] . "');";

$result=mysql_query($sql);
if(!$result){
die('FAILED TO INPUT INTO DATABASE:' . mysql_error());
}
header("Location: index.php?id=" . $validentry);
}

?>
<center>
**All dates must be inputted in the YYYY-MM-DD format**



<form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post">
<table>

<tr>
<td>Topic</td>
<td><input type="text" name="topic"></td>
</tr>
<tr>
<td>Date</td>
<td><input type="text" name="lname"></td>
</tr>
<tr>
<td>Comment</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit Note"></td>
</tr>
</table>
</form>
</center>
No comments posted yet

Your Answer:

Login to answer
295 Like 17 Dislike
Previous forums Next forums
Other forums

Syntax Help
Code:


im having trouble with that code snipped
Parse error: syntax error, unexpec

Error in write byte array into document in SM58
Hi Gurus,

Getting the following error status in Transactional RFC (SM58) ..... *Error i

single values into sql field
i have a form which i want the user to able to select multiple answers. But i want the answers to be

Help with PHP Calendar code...
Hello, I'm new to this forum and I'm glad I found it.
I wrote this code for a PHP calendar as an

Posting Serialized Data Not Working
I am trying to send an object from one PHP file to another using POST. I serialize the object and th

Ajax Error since Upgrading to 3.5
Ever since upgrading my site to .NET 3.5 (I needed LINQ), I've been getting this annoying error on o

Checking if variable is 0 as opposed to NULL/Empty...
I'm trying to write some code that will retrieve a user's access level from my database and if it do

DateTimeZone::listIdentifiers headache
http://php.net/manual/en/datetimezone.listidentifiers.php


So the documentation states tha

fire away
i launched about 4 months ago as a lagit co. i have 2 paying clients, 1probono, 1 side progect, and

PHP FTP connect doesn't work with correct login
Hi!

i am working on this test code:
Quote<?php

$ftp_ser

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash