FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problems with Member System (RMB-SCRIPTING)





Diablosblizz
Hey, I am having some trouble with the Member System tutorial from Rmb-Scripting, here is the error to start off with:

Quote:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/diablosb/domains/hotelmario.info/public_html/members/config.php on line 8

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/diablosb/domains/hotelmario.info/public_html/members/register.php on line 53



I do not know what that means. Here is the register.php:

Code:
<?php
session_start(); //allows session
include "config.php";
echo "<center>";
//checks if there trying to veriy there account
if(isset($_GET['verify'])){
//gets the code and makes it safe
$code = addslashes($_GET['code']);
//gets the code from the database
$getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
//counts the number of rows
$getcode = mysql_num_rows($getcode);
//if the ammount of rows is 0 the code does not exist
if ($getcode == 0)
{
echo "Invalid verification code!";
}
//or if the code does exist we will activiate there account
else
{
//get the data from the database
$getcode=mysql_query("SELECT * FROM `verification` WHERE `code` = '$code'");
//fetchs the data from the db
$dat = mysql_fetch_array($getcode);
//sets the users user level to 2 which means they can now use there account
$update = mysql_query("UPDATE `members` SET `userlevel` = '2' WHERE `username` = '".$dat['username']."'") or die(mysql_error());
//deletes the code as there is no use of it now
$delete = mysql_query("DELETE FROM `verification` WHERE code = '$code'");
//says thanks and your account is ready for use
echo "Thank you, Your account has been verified.";
}
}
else
//if we have posted the register for we will register this user
if(isset($_GET['register'])){
//check to see if any fields were left blank
if((!$_POST[username]) || (!$_POST[password]) || (!$_POST[cpassword]) || (!$_POST[email])){
echo "A field was left blank please go back and try again.";
}
else
{
//posts all the data from the register form
$username = $_POST[username];
$password = $_POST[password];
$cpassword = $_POST[cpassword];
$email = $_POST[email];
//check see if the 2 passwords are the same
if($password == $cpassword)
{
//encrypts the password 8 times
$password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($password))))))));
$cname = mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username'");
$cname= mysql_num_rows($cname);
//checks to see if the username or email allready exist
if ($cname>=1) {
echo "The username is already in use";
}
else
{
//gets rid of bad stuff from there username and email
$username = addslashes(htmlspecialchars($username));
$email = addslashes(htmlspecialchars($email));
//adds them to the db
$adduser = mysql_query("INSERT INTO `members` (`username`, `password`, `email`) VALUES('$username','$password','$email')");
//posible letters for the verification code
$alphanum  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
//shuffles the letters around to create a 16 long code
$code = substr(str_shuffle($alphanum), 0, 16);
//adds there code along with there user name to the db
$addcode = mysql_query("INSERT INTO `verification` (`username`, `code`) VALUES('$username','$code')");
//don't edit this, this is the link for there activication
$link = "http://$host$self?verify&code=$code";
//sends the email to the person
mail("$email", "Member-Ship Validation", "Thank you for registering on $sitename.
Please copy the below link into you address bar,

$link", "From: Site Verification");
//message sent now lets tell them to check there email
echo "You are now registered,<br><br>Please check your email to activate your account.";
}
}
else
{
echo "Your password and conformation password do not match!";
}
}
}
else
{
//none of the above so lets show the register form
echo "<form action='register.php?register' method='post'>
<fieldset style='width: 350'>
<table width='350'>
  <tr>
    <td width='150'>Username:</td>
    <td width='200'><input type='text' name='username' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input type='password' name='password' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Confirm Password:</td>
    <td><input type='password' name='cpassword' size='30' maxlength='25'></td>
  </tr>
  <tr>
    <td>Email:</td>
    <td><input type='text' name='email' size='30' maxlength='55'></td>
  </tr>
  <tr>
    <td colspan='2'><center><input type='submit' value='Register'></center></td>
  </tr>
</table>
</fieldset>
</form>";
}
echo "<center>";
?>


Any ideas? Thank you.
MrBlueSky
Quote:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/diablosb/domains/hotelmario.info/public_html/members/config.php on line 8


means that in config.php you try to apply mysql_fetch_array on an empty result set from a dbase-query.
DanielXP
Have you run the SQL in phpMyAdmin?

http://rmb-scripting.com/tutorials.php?tutorial&tid=58

Where it says 'Run this query'
Diablosblizz
Rofl, I just thought about that this morning. Thanks for the reminder.

Thanks for the awesome member system too!
Related topics
User Membership Script Needed....In Trouble really need 1 !
RMB Scripting
Is there any code to...
another question for all the PHP gods out there..........^^
RMB Scripting ~ Tutorial Site
AJAX and PHP rating system
PHP Member System (using FOPEN)..
Creating a member system
Script to check if Session has started?
Website login?
Problems with php + mysql script.
Flex + PHP login
register/login mysql
Problem with Member system(or template) and $_GET[id]
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.