DiscoTrio Posted December 22, 2009 Share Posted December 22, 2009 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>";}} Quote Link to comment Share on other sites More sharing options...
DiscoTrio Posted December 22, 2009 Author Share Posted December 22, 2009 By the way error reporting gives me nothing. Quote Link to comment Share on other sites More sharing options...
teynon Posted December 22, 2009 Share Posted December 22, 2009 I dont see where you are using $id Quote Link to comment Share on other sites More sharing options...
DiscoTrio Posted December 22, 2009 Author Share Posted December 22, 2009 Sorry, ive been messing around with variables a while now, it $forum in script above. But still echo's out right data with that variable... Wont write it to 'parent' in database... Quote Link to comment Share on other sites More sharing options...
teynon Posted December 22, 2009 Share Posted December 22, 2009 Check the table structure for "parent" and ensure that the data matches the type of information being stored IE parent int(11) should store an integer. A string would result in 0 Quote Link to comment Share on other sites More sharing options...
DiscoTrio Posted December 22, 2009 Author Share Posted December 22, 2009 so medium(INT) 100 wouldnt work? By the way the data im trying to store is a number. Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted December 22, 2009 Share Posted December 22, 2009 add: or trigger_error (mysql_error()); to your query. Quote Link to comment Share on other sites More sharing options...
DiscoTrio Posted December 22, 2009 Author Share Posted December 22, 2009 NO errors found, and I changed up the type of variable, name of colomb in database, and type in database. Its weird.... Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted December 22, 2009 Share Posted December 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
DiscoTrio Posted December 22, 2009 Author Share Posted December 22, 2009 didnt get the value in the echo, If its in the query it doesnt work, but if I just echo the variable itself it works........... Quote Link to comment Share on other sites More sharing options...
mrMarcus Posted December 22, 2009 Share Posted December 22, 2009 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. Quote Link to comment Share on other sites More sharing options...
DiscoTrio Posted December 22, 2009 Author Share Posted December 22, 2009 O, I found the problem, I had to make sure it was in the address again when I clicked the button. I forgot about that Thanx guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.