3 messages in com.mysql.lists.perlI cant Insert anything
FromSent OnAttachments
Graham Haigh26 Feb 2001 10:12 
ed phillips26 Feb 2001 11:07 
Paul A. Rubin02 Mar 2001 13:44 
Subject:I cant Insert anything
From:Graham Haigh (gra@technetworks.co.uk)
Date:02/26/2001 10:12:36 AM
List:com.mysql.lists.perl

Hi,

I am using the code listed below to add records to my user d/b BUT for some reason when i run this and then check from the mysqladmin with SELECT * FROM Web_User the table is empty ... i have given the user Web_User SELECT,INSERT,UPDATE on the table Web_User ..are there any more permissions i need to set !?

thanks Graham

------------------------------------------------------------------------

------------------------------------------------------------------------

-----------------------------------------------------------

#!/usr/bin/perl

use strict; use CGI; use DBI;

my $cgi=new CGI; my $salt=join '',('.','/',0..9,'A'..'Z','a'..'z')[rand 64, rand 64]; my ($name,$address,$email,$university,$course); my ($username,$password,$passwordrem,$confpassword); my ($result,$line);

$name=$cgi->param('name'),$address=$cgi->param('address'),$email=$cgi->p aram('email'),$university=$cgi->param('university'),$course=$cgi->param( 'course'); $username=$cgi->param('username'),$password=$cgi->param('password'),$pas swordrem=$cgi->param('passwordrem'),$confpassword=$cgi->param('confpassw ord'); $result=crypt($password,$salt);

print $cgi->header(); print "Start";

&add_user($username,$email,$name,$address,$university,$course,$result); print $cgi->end_html();

sub add_user{ my ($db_conn,$sql,$db_rtn); my ($username,$name,$address,$email,$university,$course,$passwd); my ($mysql_host,$mysql_db,$mysql_user,$mysql_passwd,$mysql_table);

$mysql_host='127.0.0.1'; $mysql_db='Course_Books'; $mysql_user='web_login'; $mysql_passwd='readonly'; $mysql_table='Web_User';

$_[0]=$username; $_[1]=$email; $_[2]=$name; $_[3]=$address; $_[4]=$university; $_[5]=$course; $_[6]=$passwd;

$db_conn = DBI->connect("dbi:mysql:$mysql_db",$mysql_user,$mysql_passwd) || die "Opening Databse Failed"; print "middle"; $sql="INSERT INTO Web_User (Username,Email,Name,Address,University,Course,Password) VALUES ($username,$email,$name,$address,$university,$course,$passwd)"; $db_rtn = $db_conn->prepare($sql) or die "Failed prepare"; $db_rtn->finish; $db_conn->disconnect();

print "Finished"; }