insert problem!

Codes here !

Moderators: macek, egami, gesf

php-punk
New php-forum User
New php-forum User
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk
Contact:

insert problem!

Postby php-punk » Thu Feb 20, 2003 10:01 am

rite, im bk again, with yet another prob..

i have a HTML form and a PHP file to get the variables from teh form and insert them into a mySQL table:

The code!:
The HTML

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Straight to the point - Guest Book</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body text="#999999">
<form Name="Add" action="add.php" method="post">
<p><b>Name</B></p>
<p><input name="name" type="text" Maxlength="25"></p>
<p><B>E-Mail</B></p>
<p><input name="mail" type="text" maxlength="25"></p>
<P><b>Website</b>(if Available)</P>
<p><input name="site" type="text" maxlength"25"></p>
<p><b>Post For GuestBook</b></p>
  <p>
    <textarea name="post" cols="30" rows="5" wrap="PHYSICAL"></textarea>
  </p>
  <p>
    <input name="submit" type="submit" value="Submit">
  </p>
<input name="status" type="text">
</form>

</body>
</html>


The PHP Form:[b]

Code: Select all

<?PHP
//connect to the DB
$Connect=mysql_connect(localhost,***,***);
//select DB
$DB=mysql_select_db(DB);
// insert in to adamgb table: Fields, ID NAME DATE MAIL SITE POST  , values in field order, ID - auto incremented NAME, date(auto) MAIL, SITE, POST


$query="INSERT INTO `adamgb` (`id`, `name`, `date`, `mail`, `site`, `post`) VALUES ('', '$name', '', '$mail', '$site', '$post');  ";
mysql_query($query);
echo("Your Comments were Entered into the Straight To The Point GuestBook, thanx!!")
?>


i dont know were i am going wrong, can n e 1 please help!?

grately appreciated!!

Tony121076
New php-forum User
New php-forum User
Posts: 28
Joined: Fri Jan 03, 2003 4:00 pm

Remove the quotes from the table name

Postby Tony121076 » Thu Feb 20, 2003 1:28 pm

Remove the quotes from the table name...

$query="INSERT INTO adamgb (`id`, `name`, `date`, `mail`, `site`, `post`) VALUES ('', '$name', '', '$mail', '$site', '$post'); ";

php-punk
New php-forum User
New php-forum User
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk
Contact:

thx....but..:X

Postby php-punk » Thu Feb 20, 2003 1:56 pm

thx, i did that, and i also added 'or die("")' after each point were it connects, and i found that i stops at (2):

Code: Select all

<?php
//connect to the DB
$Connect=mysql_connect(localhost,***,***) or die ("sorry unable to connect(1)");
//select DB
$DB=mysql_select_db(***) or die ("sorry unable to select DB");
// insert in to adamgb table: Fields, ID NAME DATE MAIL SITE POST  , values in field order, ID - auto incremented NAME, date(auto) MAIL, SITE, POST


$query="INSERT INTO `adamgb` (`id`, `name`, `date`, `mail`, `site`, `post`) VALUES ('', '$name', '', '$mail', '$site', '$post'); ";

mysql_query($query) or die ("Sorry unable to connect(2)");

echo("Your Comments were Entered into the Straight To The Point GuestBook, thanx!!");

echo("<a><Href http://members.lycos.co.uk/stu3sk8r/adam/display.php>View GuestBook</a>")
?>


any help would be apriciated

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Thu Feb 20, 2003 2:06 pm

Remove the quotes from the table name...


those are back ticks not quotes ' a quote ` a back tick

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Thu Feb 20, 2003 2:09 pm

php-punk if you are getting your information from a post form then your code is not register_globals=off compliant.

php-punk
New php-forum User
New php-forum User
Posts: 60
Joined: Sun Feb 02, 2003 2:10 am
Location: Leeds, Uk
Contact:

Postby php-punk » Thu Feb 20, 2003 2:27 pm

so is there anyway i am able to make it work!?


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests

cron