Current location: Hot Scripts Forums » General Community » Script Requests » erron in this code?


erron in this code?

Reply
  #1 (permalink)  
Old 09-30-03, 03:37 AM
alvibd alvibd is offline
New Member
 
Join Date: Sep 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
erron in this code?

pls tel me what is wrong i am doing here...?

Table name: tutor
form value:email,password

i am getting email and password from a form and want to store that in a database named "nikitah_tbd"
but the following codes shows error....
ple help...


<?php

$dbh=mysql_connect ("localhost", "teacher", "mypasswd") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("nikitah_tbd");

if (!$dbh) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}

// Select the jokes database
if (! @mysql_select_db("nikitah_tbd") ) {
echo( "<P>Unable to locate the TUITIONBD " .
"database at this time.</P>" );
exit();
}

// If a email and pass is given
// add it to the database.

$sql = "INSERT INTO tutor SET".
"email='$email', " .
"paswd='$password';"
if (mysql_query($sql)) {
echo("<P>Your E-mail address has been added</P>");
} else {
echo("<P>Error adding submitted email " .
mysql_error() . "</P>");
}

?>
Reply With Quote
  #2 (permalink)  
Old 09-30-03, 12:49 PM
jewellgr jewellgr is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Michigan USA
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Replace what you have for inserting with this:
PHP Code:

$sql "INSERT INTO tutor VALUES ('" $email "','" .$password "')";

$result mysql_query($sql);

if (
$result)
  echo(
"<P>Your E-mail address has been added</P>");
else
  echo(
"<P>Error adding submitted email " mysql_error() . "</P>"); 
You do not need to put email=$email, paswd=$password because it is assumed that you are inserting a value for each field in the table.

Hope this helps
__________________
ArecaWeb Team
Gregg Kenneth Jewell

Last edited by jewellgr; 09-30-03 at 12:52 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code to edit a text file mdhall Script Requests 12 12-23-10 04:03 AM
protecting code in PHP ckb PHP 12 01-02-04 08:53 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM
Validation code for site membership kNIGits The Lounge 1 07-28-03 02:41 AM
something wrong with this code superman PHP 3 07-06-03 10:55 PM


All times are GMT -5. The time now is 11:53 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.