Jump to content

Variable wont record to database...


DiscoTrio

Recommended Posts

The following code works perfect but on the insert query the variable $id only rcords as 0.  I have no idea why becuase if I echo that variable it shows correctly...

 

The $id is in a address.

 

	if ($action == 'new_topic'){echo "<a href='forum.php?action=view'>GamePage101 Forums</a> >> <a href='$currentpage'>$forumname</a>";
echo "<form action='$currentpage?action=new_topic&go=post' method='POST'>";
echo "<br>Title:<br><input name='title' id='title' size='100'>";
echo "<br><br><textarea name='content' id='content' style='width:700px;height:400px;'></textarea>";
echo "<br><br><input type=submit value=Post></form>";
	if ($go == 'post'){
	if (!$title || !$content) {print "You must fill out all fields.";}
	if ($session->username == 'Guest') {print "You must be signed in to post.";}
	mysql_query ("INSERT INTO `bmvybfbk_website`.`forum` (`id2`, `title`, `content`, `writer`, `parent`)VALUES ('3', '$title', '$content', '$session->username', '$forum');");
	echo "<b>Posted, <a href='$currentpage'>Click here</a></b>";}}

Link to comment
Share on other sites

not so much weird as it is going to be something that you are overlooking.  echo your query by removing the mysql_query():

 

$sql = "INSERT INTO `bmvybfbk_website`.`forum` (`id2`, `title`, `content`, `writer`, `parent`)VALUES ('3', '$title', '$content', '$session->username', '$forum')";
echo $sql;

 

and see if everything matches up.

Link to comment
Share on other sites

so, if you were to echo $forum right above the query, it'd give a value?

 

echo $forum; // 2
$sql = "INSERT INTO `bmvybfbk_website`.`forum` (`id2`, `title`, `content`, `writer`, `parent`)VALUES ('3', '$title', '$content', '$session->username', '$forum')";
echo $sql;

 

let's see how you're defining $forum, 'cause it's not making any sense as to why it's not making it to the query.

Link to comment
Share on other sites

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.