Jump to content

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]
Link to comment
https://forums.phpfreaks.com/topic/10199-why-wont-this-code-work/
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
[!--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
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.