/    Sign up×
Community /Pin to ProfileBookmark

Problem with user registration?

Hi there,
I’m new to all this coding, but I can understand a bit of what it all means.
Anyways!
When ever I try to register a new user I keep getting this error –

Warning: mysql_result(): Unable to jump to row 2 on MySQL result index 15 in /home/fhlinux183/m/mrfree.co.uk/user/htdocs/register.php on line 77

The url is [url]www.mrfree.co.uk/register.php-[/url] so you can see for yourself.

Oh yeah here is the register .php code

[code=php]<?
define(‘IN_RAFS’, true);
include “./sessions.php”;
include ‘includes/header.php’;

$page = “Register”;
$adsense = “no”;
if ( $_SESSION[‘username’] != NULL ) {
header(“Location: index.php”);
}
else {
// $username = ereg_replace(“[^A-Za-z0-9]”, “”, strtolower(strip_tags($_POST[‘username’])));
$password = sql_sanitize($_POST[‘password’]);
$cpassword = sql_sanitize($_POST[‘cpassword’]);
$enpassword = md5(base64_encode(md5($password)));
$email = sql_sanitize($_POST[’email’]);
$cemail = sql_sanitize($_POST[‘cemail’]);
$username = $email;
$robotkey = sql_sanitize($_POST[‘rokey’]);
$fullname = sql_sanitize($_POST[‘fullname’]);
$street = sql_sanitize($_POST[‘street’]);
$city = sql_sanitize($_POST[‘city’]);
$county = sql_sanitize($_POST[‘county’]);
$postcode = sql_sanitize($_POST[‘postcode’]);
$referral = sql_sanitize($_POST[‘referral’]);
$item = sql_sanitize($_POST[‘item’]);
$ip = sql_sanitize($_SERVER[‘REMOTE_ADDR’]);
$time = time();
$key = md5($time);
$date = date(“dgdijmzy”);
$birthday_month = sql_sanitize($_POST[‘birthday_month’]);
$birthday_day = sql_sanitize($_POST[‘birthday_day’]);
$birthday_year = sql_sanitize($_POST[‘birthday_year’]);
$birthday = $birthday_month . “/” . $birthday_day . “/” . $birthday_year;
$sid = session_id();
if ( $sid != NULL ) {
$get = “SELECT `key` FROM `robot` WHERE `sid` = ‘$sid'”;
$rkey = @mysql_result(mysql_query($get), 0);
}
else {
}
if (isset($_GET[’email’])) {
if (isset($_GET[‘referral’])) {
$referral = $_GET[‘referral’];
$referral_email = “SELECT `email` FROM `users` WHERE `id` = ‘$referral'”;
$referral_email2 = @mysql_result(mysql_query($referral_email), 0);
$referral_text = “<BR>You are being referred by <B>” . $referral_email2 . “</B>”;
}
else {
$referral = 0;
}
$tvars = array(
‘EMAIL’ => $_GET[’email’],
‘ITEM’ => $_GET[‘item’],
‘REFERRAL’ => $referral,
‘REFERRAL_EMAIL’ => $referral_text,
‘SID’ => $sid
);

pparse(‘register_form’);
exit;
}
if ($username != NULL && $password != NULL && $email != NULL && $robotkey != NULL && $email == $cemail && $password == $cpassword && $fullname != NULL && $street != NULL && $city != NULL && $county != NULL && $postcode != NULL && $birthday_month != NULL && $birthday_day != NULL && $birthday_year != NULL) {
$sqlsid = session_id();
$exists = mysql_query(“SELECT * from users WHERE username=’$username’ or email=’$email'”);
$user_exists = mysql_fetch_array($exists);
$ipcheck = mysql_query(“SELECT * from users WHERE ip=’$ip'”);
$ip_exists = mysql_fetch_array($ipcheck);
echo $_SESSION[“autamationcode”];
// if ( $user_exists == “0” && $ip_exists == “0” && $robotkey == $rkey ) {
if ( $user_exists == “0” && $robotkey == $rkey ) {
$sql = “INSERT INTO users (id, username, password, email, ip, account, active, name, street, city, county, postcode, referral, status, item, birthday)”.”VALUES (‘NULL’, ‘$username’, ‘$enpassword’, ‘$email’, ‘$ip’, ‘0’, ‘$key’, ‘$fullname’, ‘$street’, ‘$city’, ‘$county’, ‘$postcode’, ‘$referral’, ‘1’, ‘$item’, ‘$birthday’)”;
mysql_query($sql);
$clearsid = “DELETE FROM `robot` WHERE `sid` = ‘$sid'”;
mysql_query($clearsid);
$uid = mysql_query(“SELECT id from users WHERE username=’$username'”);
$u = mysql_result($uid,0);
$message = “Thank your for registering! You’re just one step away from being registered on MrFree!. Please check the e-mail you provided during registration just there. You were sent an activation link, just visit it and your account will be active and ready to go!Oh and Good Luck getting your free gift from MrFree!”;
$tvars = array(
‘message’ => $message);
pparse(‘message_body’);
mail($email, “Welcome to ” . $domain, “Thank you for registering at ” . $domain . “!nnBefore you can get started, you need to activate your account, use the link below to do sonnhttp://” . $domain . “/activate.php?id=” . $u . “&k=” . $key . “nnOnce activated, you can login to your account with the following details:nnUsername: ” . $username . “nPassword: ” . $password . “nnIf you have any problems please contact us.nnThanks,n” . $domain, “From: ” . $domain . ” <support@” . $domain . “>”);
}
elseif ( $robotkey != $rkey ) {
$back_link = “register.php?item=” . $_POST[‘item’] . “&email=” . $_POST[’email’] . “&referral=” . $_POST[‘referral’];
$message = “Please make sure you typed the signup key properly.<br /><br />Click <a href=”” . $back_link . “”>here</a> to go back.”;
$clearsid = “DELETE FROM `robot` WHERE `sid` = ‘$sid'”;
mysql_query($clearsid);
$tvars = array(
‘message’ => $message);
pparse(‘message_body’);
}
elseif ( $user_exists != “0” ) {
$back_link = “register.php?item=” . $_POST[‘item’] . “&email=” . $_POST[’email’] . “&referral=” . $_POST[‘referral’];
$message = “Sorry but either your username or e-mail are already in use.<br /><br />Click <a href=”” . $back_link . “”>here</a> to go back.”;
$clearsid = “DELETE FROM `robot` WHERE `sid` = ‘$sid'”;
mysql_query($clearsid);
$tvars = array(
‘message’ => $message);
pparse(‘message_body’);
}
}
elseif ( $_POST == NULL ) {

$tvars = array(
’email’ => $_GET[’email’],
‘cemail’ => $_GET[’email’],
‘ITEM’ => $_GET[‘item’],
‘REFERRAL’ => $referral,
‘REFERRAL_EMAIL’ => $referral_text,
‘SID’ => $sid
);

pparse(‘register_form’);
}
elseif ( $username != NULL && $password != NULL && $email != NULL && $cpassword != NULL && $cemail != NULL && $password != $cpassword ) {
$back_link = “register.php?item=” . $_POST[‘item’] . “&email=” . $_POST[’email’] . “&referral=” . $_POST[‘referral’];
$message = “Your passwords do not match.<br /><br />Click <a href=”” . $back_link . “”>here</a> to go back.”;
$clearsid = “DELETE FROM `robot` WHERE `sid` = ‘$sid'”;
mysql_query($clearsid);
$tvars = array(
‘message’ => $message);
pparse(‘message_body’);
}
elseif ( $username != NULL && $password != NULL && $email != NULL && $cpassword != NULL && $cemail != NULL && $email != $cemail ) {
$back_link = “register.php?item=” . $_POST[‘item’] . “&email=” . $_POST[’email’] . “&referral=” . $_POST[‘referral’];
$message = “Your email does not match.<br /><br />Click <a href=”” . $back_link . “”>here</a> to go back.”;
$clearsid = “DELETE FROM `robot` WHERE `sid` = ‘$sid'”;
mysql_query($clearsid);
$tvars = array(
‘message’ => $message);
pparse(‘message_body’);
}
elseif ( $_POST != NULL && $username == NULL or $password == NULL or $email == NULL or $cpassword == NULL or $cemail == NULL or $fullname == NULL or $street == NULL or $city == NULL or $state == NULL or $zip == NULL or $birthday_month == NULL or $birthday_day == NULL or $birthday_year == NULL ) {
$back_link = “register.php?item=” . $_POST[‘item’] . “&email=” . $_POST[’email’] . “&referral=” . $_POST[‘referral’];
$message = “Please fill in all the required fields before submitting.<br /><br />Click <a href=”” . $back_link . “”>here</a> to go back.”;
$clearsid = “DELETE FROM `robot` WHERE `sid` = ‘$sid'”;
mysql_query($clearsid);
$tvars = array(
‘message’ => $message);
pparse(‘message_body’);
}
//mysql_close($connect);
}
include ‘includes/footer.php’;
?>[/code]

Thanks Saul

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 09.2006 — The error message does not match well with the supplied code, as you're specifying row 0 while the error message implies you're specifying row 2. All I can suggest is to put in some debug code before that line, starting with the query line above it:
[code=php]
//
$uid = mysql_query("SELECT id from users WHERE username='$username'") or
die("Query failed: ".mysql_error());
if(!mysql_num_rows($uid))
{
user_error("Query returned 0 rows.", E_USER_ERROR);
}
$u = mysql_result($uid,0);
[/code]
×

Success!

Help @racerace1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...