What's wrong with this code?

Reply

Join Date: Nov 2005
Posts: 4
Reputation: leprakhauns is an unknown quantity at this point 
Solved Threads: 0
leprakhauns leprakhauns is offline Offline
Newbie Poster

What's wrong with this code?

 
0
  #1
Jan 11th, 2006
<form action="php.php?b=<?php echo $b; ?>" method="post">

Enter your news/rumor:
<input type="text" name="name" />
Enter your news/rumor:
<input type="text" name="website" />
Enter your news/rumor:
<input type="text" name="comment" />
<input type="submit" />
</form><br />

then on php.php:

$t=$_GET["b"];
mysql_connect("db.lepslair.com", "username", "my password");
mysql_select_db("lepslair");
mysql_query("INSERT INTO nonmembers($name, $website, $comment)) VALUES(name, website, post_text) ");

I'm not getting any errors thrown at me, but the database doesn't retain any of the information.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: What's wrong with this code?

 
0
  #2
Jan 12th, 2006
this line
  1. mysql_query("INSERT INTO nonmembers($name, $website, $comment)) VALUES(name, website, post_text) ");
should read
  1. mysql_query("INSERT INTO nonmembers (name, website, post_text) VALUES ('$name', '$website', '$comment')");
or to be really good
  1. $sql = "INSERT INTO `nonmembers` (`name`, `website`, `post_text`) VALUES ('{$name}', '{$website}', '{$comment}');
  2. mysql_query($sql) or die(mysql_error() . '<br>' . $sql);
  3.  
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 4
Reputation: leprakhauns is an unknown quantity at this point 
Solved Threads: 0
leprakhauns leprakhauns is offline Offline
Newbie Poster

Re: What's wrong with this code?

 
0
  #3
Jan 12th, 2006
LMAO I should have known that, thanks for pointing it out. It works now thanks a lot.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1496 | Replies: 2
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC