Page 1 of 1
multi comment table
Posted: Fri Sep 23, 2005 2:35 pm
by Smackie
I am making a site for a friend that has multi comment tables ok and well they all are going to use the same table as each other and will im making a filter for it now each one will have a hidden field called filter as you can see in this form..
Code: Select all
<form action="insert.php" METHOD="post">
<br><br><br><font color="B5B5B5">username:</font><br>
<input type="text" name="username" size="30" value=""><br>
<font color="B5B5B5">text to add:</font><br>
<input type="text" name="message" size="30" value=""><br>
<input name="filter" type="hidden" value="comment1">
<p><input type="submit" name="submit" value="Submit">
</form>
and here is the insert.php
Code: Select all
<?php
include 'db.php';
$username = $_POST['username'];
$message = $_POST['message'];
$filter = $_POST['filter'];
mysql_query("INSERT INTO gallery (username, message, filter, date) VALUES ('".$username."', '".$message."', '".$filter."', now())") or die(MySQL_Error());
header ("Location: icomment1.php");
?>
now i dont get a error but everything gets put in but the filter can someone help me out here please...
Thank you
Smackie
Posted: Fri Sep 23, 2005 2:37 pm
by Charles256
what kind of datatype is "filter" set to recieve in your database?
Posted: Fri Sep 23, 2005 2:39 pm
by Smackie
i have it as Varchar but i dont know if it should be something else in there

Posted: Fri Sep 23, 2005 2:45 pm
by Charles256
and how many varchars can it accept? I know it seems stupid to ask but your code looks okay to me.....i could be missing something,it wouldn't be the first time;)
Posted: Fri Sep 23, 2005 2:46 pm
by Smackie
well i set the limit at 25.. i must be missing something lol but i guess its because i have family over for the week and im just distracted lol
Posted: Fri Sep 23, 2005 2:49 pm
by Charles256
hm.well if someone else comes up with a solution go with them.but a cheap workaround is to make a table called comment1 and set filter in that table to default to comment1.. :: shrugs :: also, i can't find a now() function BTW, where the devil is that? either way. sorry i couldn't be more help.
Posted: Fri Sep 23, 2005 2:52 pm
by Smackie
now() function is for the date..
Posted: Fri Sep 23, 2005 2:53 pm
by ryanlwh
Charles, NOW() is a mysql function. check the mysql manual.
Smackie, try echoing the filter out and see what's on screen. I don't see anything wrong with your code.
Posted: Fri Sep 23, 2005 2:54 pm
by Charles256
i know what it's sposed to do but i couldn't find a now() function in the php manual. maybe i just can't type :: shrugs ::
ah ha. a mysql function!

i'll go read up on the later,thanks!
we've really gotta slow down our posting and editing children... hehe
Posted: Fri Sep 23, 2005 2:57 pm
by Smackie
see on the table in database under filter it shows nothing going in there...
Posted: Fri Sep 23, 2005 3:05 pm
by ryanlwh
that's why you should echo all the variables to see what's being output to the screen. you can also view source to see what's happening.
Did you put some quotes into the message? and btw, should message be in a textarea, not a text field?
Posted: Fri Sep 23, 2005 3:19 pm
by Smackie
I got it working heres how i fixed it
Code: Select all
mysql_query("INSERT INTO gallery (username, message, filter, date) VALUES ('".$username."', '".$message."', '".$filter."', now())") or die(MySQL_Error());
all i had to do was
Code: Select all
mysql_query("INSERT INTO gallery (username, message, filter, date) VALUES ('$username', '$message', '$filter', now())") or die(MySQL_Error());
but thank you all for your help
Smackie
Posted: Fri Sep 23, 2005 3:22 pm
by Charles256
in theory those should be the same thing...go SQL:-D
Posted: Fri Sep 23, 2005 3:27 pm
by ryanlwh
Charles256 wrote:in theory those should be the same thing...go SQL:-D
Indeed. In PHP or Perl those two would produce the same string...
Probably just some random error unrelated to how the string was constructed... anyway, it's solved...