Geowil
12-08-2008, 11:32 AM
Alright, I finally got this ccbill bs to work correctly after a week, so I am thinking of throwing a bloody party (j/k)
but, first I need to fix one problem. I still need to set up the script so that it writes to my database so my user accounts can get made.
Now I already have a script that does do this for a test table, but for the real thing there is a complication. There is a user Id field. each id has to be different or else the insert fails.
so. when I had this thing phpified I had a for loop, that was supposed to work but didnt, that would keep incrementing the user id by 1 until data insert did not fail.
but the coding for cgi/pearl is way different so I am not sure how to do something like that.
right now this is what I have:
#!/usr/bin/perl
use DBI;
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $cgi = new CGI;
my $user = $cgi->param("username");
my $pass = $cgi->param("password");
my $email = $cgi->param("email");
my $g_id = 0;
$dbh = DBI->connect("DBI:mysql:xilohen_XiloGallery:localhost","username","password") or die "Error: $DBI::errstr\n";
my $sql = "INSERT INTO g2_user (g_id, g_userName, g_fullName, g_password, g_email, g_language, g_locked) VALUES ('$g_id','$user','NULL','$pass','$email','NULL','0')";
$sth = $dbh->prepare($sql);
$sth->execute;
$dbh->do($sql);
$dbh->disconnect;
So, what I was thinking was, how can I code a query to see if the g_id, in this case 0, is present, then add one to it and check again, and repeate the process until the id is not found. Then go on to do the INSERT INTO code.
thanks.
but, first I need to fix one problem. I still need to set up the script so that it writes to my database so my user accounts can get made.
Now I already have a script that does do this for a test table, but for the real thing there is a complication. There is a user Id field. each id has to be different or else the insert fails.
so. when I had this thing phpified I had a for loop, that was supposed to work but didnt, that would keep incrementing the user id by 1 until data insert did not fail.
but the coding for cgi/pearl is way different so I am not sure how to do something like that.
right now this is what I have:
#!/usr/bin/perl
use DBI;
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
my $cgi = new CGI;
my $user = $cgi->param("username");
my $pass = $cgi->param("password");
my $email = $cgi->param("email");
my $g_id = 0;
$dbh = DBI->connect("DBI:mysql:xilohen_XiloGallery:localhost","username","password") or die "Error: $DBI::errstr\n";
my $sql = "INSERT INTO g2_user (g_id, g_userName, g_fullName, g_password, g_email, g_language, g_locked) VALUES ('$g_id','$user','NULL','$pass','$email','NULL','0')";
$sth = $dbh->prepare($sql);
$sth->execute;
$dbh->do($sql);
$dbh->disconnect;
So, what I was thinking was, how can I code a query to see if the g_id, in this case 0, is present, then add one to it and check again, and repeate the process until the id is not found. Then go on to do the INSERT INTO code.
thanks.