Jump to content

supplied argument is not a valid MySQL-Link


a1amattyj

Recommended Posts

Hello,

 

I get the followign error when i process this script:

 

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/aceinstr/public_html/ifus_admin/register.php on line 55

 

Script:

 

<?php
$dbname = '**';
$dbuser = '**';
$dbpass = '**';
$domain = '**';
mysql_connect("localhost", $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
if(isset($_COOKIE['Username']) && isset($_COOKIE['login']) && isset($_COOKIE['id'])){
echo "<div class='error_msg'>ERROR: You have already a account.</div>";
}else{
if(!isset($_GET['act'])){
?>
<b>Fill in your account details to register.</b><br>
<form action='register.php?act=reg' method='post'>
<p>Username:<input type='text' name='user'></p>
<p>Password: <input type='password' name='pass'></p>
<p>Confirm Password: <input type='password' name='pass2'></p>
<p>E-Mail: <input type='text' name='email'></p>
<script> document.write("<p><input type='submit' value='Register'></p>"); </script><p><noscript><div class='error_msg'>ERROR: Please enable javascript to register.</div></noscript></p>
</form>
<?
}
if($_GET['act']=='reg'){
$a = $_POST['user'];
$b = $_POST['pass'];
$c = $_POST['pass2'];
$d = $_POST['email'];
$e = 0;
if($a==''){
echo "<div class='error_msg'>ERROR: Please fill in your username.</div>";
$e = 1;
}
if(strlen($a)>15 || strlen($a)<5 && $e!=1){
echo "<div class='error_msg'>ERROR: Your username must be between 5-15 characters.</div>";
$e=1;
}
if($b=='' && $e!=1){
echo "<div class='error_msg'>ERROR: Please fill in your password.</div>";
$e = 1;
}
if(strlen($b)>20 || strlen($b)<5 && $e!=1){
echo "<div class='error_msg'>ERROR: Your password must be between 5-20 characters.</div>";
$e = 1;
}
if($b!=$c && $e!=1){
echo "<div class='error_msg'>ERROR: Passwords didn't matched.</div>";
$e = 1;
}
if(!strstr($d, "@") && !strstr($d, ".") && $e!=1){
echo "<div class='error_msg'>ERROR: Please enter a real email address in.</div>";
$e = 1;
}
if($e==0){
$query = "SELECT * FROM users WHERE Username = '$a'";
$result = mysql_query($query) or die(mysql_error($query));
$checkdone = mysql_num_rows($result);
if($checkdone==1){
echo "<div class='error_msg'>ERROR: Username is already taken.</div>";
}else{
$username = mysql_real_escape_string($a);
$password = md5(mysql_real_escape_string($b));
$email = mysql_real_escape_string($d);
$join_date = date('dS \of F Y');
$ip = $_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO users
(Username, Password_MD5, Email, Join_date, IP) VALUES('$username', '$password', '$email', '$join_date', '$ip' ) ")
or die(mysql_error());
echo "<b>Registration was successful!</b>";
}}
}}
?>

 

Any ideas? Thanks.

 

P.S i hashed out the password and users.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.