SOLVED: Little coding help

If you've problems with unsupported - non official ;-) - functionalities use this forum please.
Post Reply
Marko
Posts: 65
Joined: Tue 2. Dec 2003, 23:58
Location: Finland

SOLVED: Little coding help

Post by Marko »

Hi guys!

Well, please forgive for beeing such a bonehead, but I could really use some help on this one... I'm trying to include an extra field to guestbook table for admin comments. So far I have added the field and I have also altered act_guestbook.php to look for that particular field. So far so good. Now comes the tricky part for me:

Lets assume I would like to insert or alter the information of the field. What kind of query I should compose? This is what I have come up with, but it doesn't work.

Code: Select all

if(isset($_POST["add_comment"])) {
		$sql  = "UPDATE ".DB_PREPEND."phpwcms_guestbook SET ";
		$sql .= "guestbook_comment=".strval($_POST['cguestbook_comment'])." WHERE guestbook_cid=";
		$sql .= intval($_POST['cid'])." AND guestbook_id=".intval($_POST['guestbook_id']);
		mysql_query($sql, $db);
}
If I replace .strval($_POST['cguestbook_comment']). with for instance with 9 it works fine...

This is the form I've created:

Code: Select all

<form action="act_guestbook.php" method="post"><input type="hidden" name="add_comment" value="10"><input type="hidden" name="cid" value="'.$row['guestbook_cid'].'"><input type="hidden" name="guestbook_id" value="'.$row['guestbook_id'].'"><textarea rows="2" cols="40" name="cguestbook_comment" wrap="VIRTUAL">'.htmlspecialchars($row['guestbook_comment']).'</textarea><input type="image" src="../../img/button/edit_22x11.gif" value="submit"></form>
PHP isn't actually my strongest area, so I have just tried to re-use Olivers code. And as you may see, I'm not very good at it... :oops:

Edit: if you can help me with this, could you also be so kind to tell that for me like I'm a 4-year old? I would really like to learn.
Last edited by Marko on Tue 18. May 2004, 03:00, edited 4 times in total.
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

did you make a database field where you are going to store the data for the new field?
http://www.studmed.dk Portal for doctors and medical students in Denmark
Marko
Posts: 65
Joined: Tue 2. Dec 2003, 23:58
Location: Finland

Post by Marko »

Yep, I did. And if I replace $sql .= "guestbook_comment=".strval($_POST['cguestbook_comment'])." WHERE guestbook_cid="; with $sql .= "guestbook_comment="something" WHERE guestbook_cid="; it works...

EDIT: Okay, I've had some progress! Now if I include statement

Code: Select all

echo strval($_POST['cguestbook_comment']);
before my SQL-query, I get the string I typed in my form. However the MySql-table itself only gets value 0... weird!

EDIT II: I quit smoking just about year ago, so I just had to rip my hair off while trying to get this work. But finally I did it!! :lol: http://www.phpwcms.de/forum/viewtopic.php?p=12233#12233
Post Reply