Gå til innhold

register.php funker ikke?


Anbefalte innlegg

Hei. Det er noe feil med scriptet mitt å jeg vet ikke hva...

 

 

Feilmelding: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/export/www/hosting/italicmafia/register1.php on line 93

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/export/www/hosting/italicmafia/register1.php on line 94

Table 'italicmafia.user_info' doesn't exist

 

 

<?php
session_start();
include_once"includes/db_connect.php";
if (isset($_SESSION['username'])){
header("Location: logged_in.php");
exit();
}

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
;$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
;$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

$curpage = curPageURL();

function parse_url_query($url) {  
$url = parse_url($url);  
$refquery = array();  
foreach(explode('&',$url['query']) as $segment) {    
list($var, $val) = explode('=', $segment);    
$refquery[$var] = $val;  
}  
return $refquery;
} 
$url= $curpage;

$refquery = parse_url_query($url);
$refusername = $refquery['ref'];

$findusername = mysql_query("SELECT username FROM users");

$refer=strip_tags($_POST['refer']);
if ($_POST['Submit']){

// Define post fields into simple variables 
$reg_username = $_POST['reg_username']; 
$reg_password = $_POST['reg_password']; 


$email = $_POST['email'];
$email1 = $_POST['email1']; 
$location=strip_tags($_POST['location']); 
$reg_username=trim($reg_username);
$gender=trim($gender);
$reg_password=trim($reg_password);




$today = gmdate('Y-m-d h:i:s');


$reg_username = stripslashes($reg_username); 
$email = stripslashes($email); 
$quote = stripslashes($quote); 
$reg_username = strip_tags($reg_username); 
$gender = strip_tags($gender); 
$email = strip_tags($email);




if((!$reg_username) || (!$email) || (!$reg_password)){
$message="Fill in all fields";
}else{
if ($email != $email1){
$message="Emails do not match";
}elseif ($email == $email1){



if (ereg('[^A-Za-z0-9]', $reg_username)) {  $message="Your username can only contain letters.";
}elseif (!ereg('[^A-Za-z0-9]', $reg_username)) {


if (strlen($reg_username) <= 3 || strlen($reg_username) >= 40){
$message= "Username too big or small.";
}elseif (strlen($reg_username) > 3 || strlen($reg_username) < 40){


$sql_email_check = mysql_query("SELECT email FROM users
           WHERE email='$email' AND status='Alive'");
$sql_username_check = mysql_query("SELECT username FROM users
           WHERE username='$reg_username'");

$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);

if(($email_check > 0) || ($username_check > 0)){
   echo "Im sorry but there has been an error please read on..<br />";
   if($email_check > 0){
       $message= "Your email address has already been used by another player!";
       unset($email);
   }
   if($username_check > 0){
       $message="Your desired username is already in use, please choose another one.";
       unset($reg_username);
   }


}else{



$userid = mysql_insert_id();
$ip = $_SERVER['REMOTE_ADDR'];

$random_password22=rand(11111,99999999);

mysql_query("INSERT INTO `user_info` ( `id` , `username`)
VALUES ('', '$reg_username')") or die (mysql_error());

mysql_query("INSERT INTO users (`id` , `username` , `password` , `regged`, `email`, `location`, `r_ip`)
VALUES ('', '$reg_username', '$reg_password', '$today', '$email', '$location', '$ip')") or die (mysql_error());

mysql_query("INSERT INTO achievements (`id` , `username`)
VALUES ('', '$reg_username')") or die (mysql_error());

mysql_query("UPDATE users SET referral=referral+1 WHERE username='$refusername'");


  $message= 'Account created, <a href="index.php"> You may now log in.</a> ';
} }}}}}

?>

<html>
<link rel="stylesheet" type="text/css" href="includes/in.css">
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>Register</title>
</head>

<body>
<form name="form2" method="post" action="">

						<? echo "$message"; ?>

				<fieldset class="row3">
				<legend><b>Username:</b></legend>
					<table class='ipbtable' cellspacing="0">
						<tr>
							<td>Enter your desired <b>Username:</b></td>

						</tr>
						<tr>
							<td>
<input name="reg_username" type="text" id="reg_username" value="" size="50" maxlength="64"></td>

						</tr>

					  </table>						

				</fieldset><br />



				<fieldset class="row3">

				<legend><b>Password:</b></legend>



					<table class='ipbtable' cellspacing="0">

						<tr>

							<td width="1%" nowrap="nowrap">Enter your 

                               password </td>

							<td width="100%">Confirm Password</td>

						</tr>



						<tr>

<td><input type="password" name="reg_password" type="text"
id="reg_password value="" size="25" maxlength="32"></td>

<td><input type="password" name="reg_password2" type="text"
id="reg_password2 value="" size="25" maxlength="32"></td>

						    <td width='12'> 

						     </td>

						</tr>

					</table>

				</fieldset><br />





				<fieldset class="row3">

				<legend><b>Email Address:</b></legend>

					<table class='ipbtable' cellspacing="0">

						<tr>

							<td width="1%" nowrap="nowrap">Enter Your Email 

                               Address </td>



<td width="100%">Confirm Email Address (If your e-mail address is
not valid you will be banned without question.) </td>

						</tr>

						<tr>

							<td><input name="email" type="text" id="username3" value="" size="25" maxlength="150" ></td>

							<td><input name="email1" type="text" id="email" value="" size="25" maxlength="150"></td>

						    <td width='12'>  

						      </td>

						</tr>

					</table>


				</fieldset>

				<!--{REQUIRED.FIELDS}-->

				<br />





				<fieldset class="row3">

				<legend><b>Starting Location:</b></legend>

					<table class='ipbtable' cellspacing="0" width="886">

						<tr>

							<td width="250" nowrap="nowrap">Starting Location:</td>



							<td width="626"> </td>

						</tr>

						<tr>

							<td width="250"><select name="location" id="starting" >

                     <option value="England">England</option>

                     <option value="Spain">Spain</option>

                     <option value="Italy">Italy</option>

                     <option value="France">France </option>

                     <option value="Sweden">Sweden </option>

                     <option value="Portugal">Portugal</option>

<input type=hidden name="ref" value="<?php echo "$_GET[ref]"; ?>"</select></td>

							<td width="626"> </td>

						    <td width='4'>  

						      </td>

						</tr>

					</table>

				</fieldset>



				<!--{REQUIRED.FIELDS}--><br>

 <p>
<fieldset class="row4">

				<legend><b>Gender:</b></legend>

					<table class='ipbtable' cellspacing="0" width="886">

						<tr>

							<td width="250" nowrap="nowrap">Gender:</td>



							<td width="626"><p align="center" style="color:white"> Gender:
           <select name="gender" class="textbox" id="select2">
             <option value="Unknown">Unknown</option>
             <option value="Male">Male</option>
             <option value="Female">Female</option>
           </select>
       </p></td>

						</tr>

						<tr>

<td><input type="submit" name="Submit" value="Register" ></td></form> </p>

<a href="index.php"> Home </a>

</body></html>

 

Takker for hjelp :)

Lenke til kommentar
Videoannonse
Annonse

Feilmeldingen er ganske beskrivende, du har noe galt på linje 93 og 94 (eller der omkring), mysql_query returerer ikke en gyldig resource.

 

 

Regner med at det er denne biten

$sql_email_check = mysql_query("SELECT email FROM users
           WHERE email='$email' AND status='Alive'");
$sql_username_check = mysql_query("SELECT username FROM users
           WHERE username='$reg_username'");
//debug
echo mysql_error($sql_username_check)."<br />";
echo mysql_error($sql_email_check);

echo "<pre>";
echo var_dump($sql_email_check);
echo var_dump($sql_username_check);
echo "</pre>";
// slutt debug

$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);

 

Mulig du trenger en space i mellom include_once og fila

//fra
include_once"includes/db_connect.php";
//til
include_once "includes/db_connect.php";

Sjekk også at du faktisk kobler til databasen.

Endret av Crowly
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...