Jump to content

[SOLVED] Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource


Recommended Posts

Im getting the error Warning:

 

mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/votick/public_html/check_login.php on line 15

Could not select database

 

from the following code ???

 

<?php

$username = $_POST['username'];
$password = $_POST['password'];
$self = $_SERVER['PHP_SELF'];
$referer = $_SERVER['HTTP_REFERER'];
$tbl_name = "banner";

# if either form field is empty return to the log-in page
if( ( !$username ) or ( !$password ) )
{ header( "Location:$referer" ); exit(); }
$$conn = mysql_connect( "==", "==", "==" )
or die( "Could not connect" );
#Select database
$rs = mysql_select_db( "votick_banner", $conn )
or die( "Could not select database" );
#Create Query
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
#execute query
$rs = mysql_query( $sql, $conn )
or die( "could not execute query" );

#get rows that match fields
$num = mysql_numrows ( $rs );

#if there is a match login is autherised
if( $num != 0 ){
session_register("username");
session_register("password");
session_register("logged_in");
header( "Location:/controls.php" ); exit();
}
else
{ header( "Location:$referer" ); exit(); }
?>

Thanks for any help.

$$conn = mysql_connect( "==", "==", "==" )

 

.....  $$....  I think you mean $ ;p.

 

$$ is used to reference the variable thats the value of the calling one....

 

Example:

 

$a = '5';
$b = 'a';
echo $$b;
//echos 5

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.