I am writing a forum site and this is an error message I randomly ran into.
I have used this code structure before but never ran into this problem.

"Fatal error: Call to undefined function form() in /home2/fellowes/public_html/comment.php on line 14"

<?php
	session_start();
	
	$tbl_name="???";
	$userid=$_SESSION[userid'];
	$username=$_SESSION['username'];
	$comment=form($_POST['txtComment']);

This "$comment=form($_POST);" is line 14 in dreamweaver

$profileid=$_GET['user_id'];
	mysql_query("INSERT INTO $tbl_name (userid, posterid, postername, pc_comment) VALUES ('$profileid', '$userid', '$username', '$comment')") or die(mysql_error());
	
	mysql_close();
?>

I have used this code before with no problem...

<form method="post" action=<?php echo "comment.php?user_id=$profileid "?> >
                      <div align="center">
                        <table width="100%" height="100%" border="0" cellspacing="0">
                            <tr>
                              <td><div align="center">
                                <textarea name="txtComment"  rows="5" ></textarea>
                              </div></td>
                            </tr>
                            <tr>
                              <td height="23"><div align="right"><input value="submit" type="submit" name="subSubmit" /></div></td>
                            </tr>
                        </table>
                      </div>
                    </form>

This is the form that the $_POST is coming from

Recommended Answers

All 11 Replies

where the form function? the error is showing because the script cant find the form function.

commented: helped me locate the problem +1

where the form function? the error is showing because the script cant find the form function.

The form is on another page.

I have used it where I have the form on one page and I set the action to the page with the php code for querying the database. and I use the post method to pull the variables from the form.

So I guess no on can help me?

you are using the "form()" function. where is it? or what are trying to do with form($_POST['txtComment']);

Ok so what I have is the one page where you view the posts and the form is located there, when I click submit it then goes to the next page where all the php code is to query the database. I have used this method before and it works thats why I am confused.

So form has an action is set to the page with the php code. I hope I was a little more clear, I have trouble with comunitcation.

I just rewrote all the code, and now its working fine. So whatever the problem was, musta been a spelling error. Thanks for the help anyways.

the reason was that you had the "form()" function on line 14.

since there wasn't a function by that name, the script threw an error.

But I literally wrote the exact same thing when I rewrote...

where the form function coming from?

You know when you Post information from a form on one page and the action is set to another page, its just like it was on the same page...

nevermind, you have no idea what i am talking about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.