Jump to content

Archived

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

legohead6

Why wont this code work?????????

Recommended Posts

when you click submit it doesnt post anything to the database

[code]<?PHP
session_start();
?>
<html>
<body bgcolor="#000000" text="#FF0000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<form method="POST">
  <p>Message:<br>
  <textarea rows="5" name="Me" cols="26"></textarea></p>
  <p><input type="submit" value="Submit" name="submit"></p>
</form>
<?php
if(isset($_POST['submit'])){
$username="***";
$password="*****";
$database="******";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$me=$_POST['Me'];
$em=$_SESSION['email'];
$cat=$_GET['cid'];
$user=$_SESSION['user'];
$id=$_GET['id'];
$query2 = "SELECT * FROM messages WHERE id=$id";
$result2 = mysql_query($query2);
$row = mysql_fetch_row($result2);
$re="RE:";
$subj="$re $row[2]";
$mes="<i><font size='2'>Original Message By $row[1]</font><br><br>$row[3]</i><br>-----------------------------<br><br>$me<br>";
$me=$_POST['Me'];
$query = "INSERT INTO messages VALUES ('','$user','$subj','$mes','$em','$cat')";
mysql_query($query);
}
$cat=$_GET['cid'];
echo "<a href='board.php?cid=$cat'>Return to menu</a>";
?>[/code]

Share this post


Link to post
Share on other sites
In your form tag, don't you need the action attribute:
[code]
<form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>">
...
[/code]

Share this post


Link to post
Share on other sites
$query = "INSERT INTO messages VALUES ('','$user','$subj','$mes','$em','$cat')";
mysql_query($query) [b]or die(mysql_error();[/b]

add that and post what it says. but also, you need to do like

insert into messages ('column','column','column') values ('blah','blah','blah')

the correct column for the variable. the only columns you can omit are the ones that a value is auto inserted upon insertion, like timestamps or auto_incremented primary keys

Share this post


Link to post
Share on other sites
[!--quoteo(post=376130:date=May 22 2006, 03:18 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 22 2006, 03:18 PM) [snapback]376130[/snapback][/div][div class=\'quotemain\'][!--quotec--]
$query = "INSERT INTO messages VALUES ('','$user','$subj','$mes','$em','$cat')";
mysql_query($query) [b]or die(mysql_error();[/b]

add that and post what it says. but also, you need to do like

insert into messages ('column','column','column') values ('blah','blah','blah')

the correct column for the variable. the only columns you can omit are the ones that a value is auto inserted upon insertion, like timestamps or auto_incremented primary keys
[/quote]
The field left blank in auto_increment

You have an error in your SQL syntax near '2'>Original Message By admin

Know you can change your own informat' at line 1

[!--quoteo(post=376138:date=May 22 2006, 03:24 PM:name=legohead6)--][div class=\'quotetop\']QUOTE(legohead6 @ May 22 2006, 03:24 PM) [snapback]376138[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The field left blank in auto_increment

You have an error in your SQL syntax near '2'>Original Message By admin

Know you can change your own informat' at line 1
[/quote]
o there we go! i fixed it! thats wierd! I though you could put singal quotes inside doubles...but it works without them!

Thanks
MAtt

Share this post


Link to post
Share on other sites

×

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.