Hi,
I'm really new to PHP so I'm sorry if any of these questions are really dumb.
I am trying to check weather people registering on my site are part of my current database. So what I have done is the following:
1. I have added two fields to the registration template. User ID number and User Membership number.
2. I have added the following code to register.php:
PHP Code:
// Custom check for membership
require_once('./includes/functions_membership.php');
if (!check_membership($_POST['memberid'], $_POST['membernumber']))
{
$errors[991] = "Invalid membership information given, please check.";
}
3. I then created a file called functions_membership.php. And put the following code in it... (I'm pretty sure this is where you will all start laughing at me

)
PHP Code:
<?php
error_reporting(E_ALL & ~E_NOTICE);
function check_membership($membershipID, $membershipnumber)
{
$SAIMClink = mysql_connect( "localhost", "myUsername", "myPassword" );
if ( ! $SAIMClink ) {
die ( "Couldn't connect to MySQL: ".mysqlerror() );
}
mysql_select_db( "saimc", $SAIMClink )
or die ( "Couldn't connect to MySQL: ".mysqlerror() );
$result = mysql_query ( "SELECT name FROM users WHERE ID = '$membershipID' AND certificateNumber = 'membershipnumber'" );
$num_rows = mysql_num_rows( $result );
$i=0;
while ($i < $num_rows) {
$NameExists = mysql_result ( $result, $i, "name" );
$i++;
}
mysql_close( $SAIMClink );
if ($NameExists != ""){
return true;
}else{
return false;
}
}
?>
When I try to go through the registration process I get the following errors:
Warning: mysql_query(): 1 is not a valid MySQL-Link resource in /includes/db_mysql.php on line 212
Warning: mysql_error(): 1 is not a valid MySQL-Link resource in /includes/db_mysql.php on line 357
Warning: mysql_errno(): 1 is not a valid MySQL-Link resource in /includes/db_mysql.php on line 358
There seems to have been a slight problem with the BB Test Forum Database.
Please try again by pressing the refresh button in your browser.
An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.
We apologise for any inconvenience.
Warning: mysql_query(): 1 is not a valid MySQL-Link resource in /includes/db_mysql.php on line 212
Warning: mysql_error(): 1 is not a valid MySQL-Link resource in /includes/db_mysql.php on line 357
Warning: mysql_errno(): 1 is not a valid MySQL-Link resource in /includes/db_mysql.php on line 358
Any ideas where I might be going wrong?