Hello all, Im trying here to connect to multiple databases and then write to each one depending on what the user inputs. But I am getting a PHP error of an invalid argument resource link (mysql_query)
Here is the DB connect
<?php
//Logs in as MySQL user
$wdp_user = mysql_connect('localhost', '******', '***************');
//checks if can login as user, if not kills application, if can continues
if(!wdp_user)
{
die('<p>Server is offline, try back later. Debug data has been logged.' .mysql_error());
}
//Selects the MySQL database
$wdp_select = mysql_select_db("********", $wdp_user);
//checks if can connect to the database. If it can, contiune, if not dies
if (!wdp_select)
{
die("<p>Sorry, there was an unrecoverable Warta database error. Debug data has been logged.</p>" .mysql_error());
}
//logs into Hufiec Picture Database
$pdp_user = mysql_connect('localhost', '********', '********');
//checks if can login as user, if not kills application, if can, continues
if(!pdp_user)
{
die("<p>Server is offline, try back later. Debug data has been logged." .mysql_error());
}
//Selects the MySQL database
$pdp_select = mysql_select_db("*******", $pdp_user);
//checks if can connect to database. If it can, continue, if not dies
if(!pdp_select)
{
die("<p>Sorry, there was an unrecoverable Picture database error. Debug data has been logged.</p>" .mysql_error());
}
//logs into Hufiec WP Database
$hwpdb = mysql_connect('localhost', '*********', '*******');
//checks if login was a success, if not kills application, if can, contiunes
if(!$hwpdb)
{
die("<p>Server is offline, try back later. Debug data has been logged." .mysql_error());
}
//selects the MySQL database
$hwpdb_select = mysql_select_db("******", $hwpdb);
//checks if can connect to database. If it can, continue, if not dies
if(!hwpdb)
{
die("<p>Sorry, there was an unrecoverable Warta Wordpress database Error. Debug data has been logged.</p>" .mysql_error());
}
?>
and here is the script running it
<?php
require_once('../wp-includes/class-phpass.php');
//connects to databases
require_once('dbconnect.php');
//Create var names
$first_name = mysql_real_escape_string($_POST['F_Name']);
$last_name = mysql_real_escape_string($_POST['L_Name']);
$phone_number_1 = mysql_real_escape_string($_POST['Pnumber1']);
$phone_number_2 = mysql_real_escape_string($_POST['Pnumber2']);
$address = mysql_real_escape_string($_POST['Address']);
$state = mysql_real_escape_string($_POST['State']);
$city = mysql_real_escape_string($_POST['City']);
$zip_code = mysql_real_escape_string($_POST['Zip']);
$email_1 = mysql_real_escape_string($_POST['Email1']);
$email_2 = mysql_real_escape_string($_POST['Email2']);
$username = mysql_real_escape_string($_POST['Uname']);
$password_1 = mysql_real_escape_string($_POST['Pass']);
$jed = mysql_real_escape_string($_POST['Jednostka']);
$dob = mysql_real_escape_string($_POST['DOB']);
$stopien = mysql_real_escape_string($_POST['Stopien']);
$funk = mysql_real_escape_string($_POST['FUNK']);
$hasher = new PasswordHash(8, True);
$password = $hasher->HashPassword($password_1);
$ENC =MD5($password_1);
$ERRmsg = "";
//Checks if any feilds were left empty and creates an error message to display
if(empty($first_name)) $ERRmsg .= 'You did not enter a First Name! Pleaase go back and try again! <br/>';
if(empty($last_name)) $ERRmsg .= 'You did not enter a Last Name! Please go back and try again! <br/>';
if(empty($phone_number_1)) $ERRmsg .= 'You did not enter a Phone Number! Please go back and try again! <br/>';
if(empty($address)) $ERRmsg .= 'You did not enter an Address! Please go back and try again! <br/>';
if(empty($state)) $ERRmsg .= 'You did not choose a State! Please go back and try again! <br/>';
if(empty($city)) $ERRmsg .= 'You did not enter a City! Please go back and try again! <br/>';
if(empty($zip_code)) $ERRmsg .= 'You did not enter a Zip Code. Please go back and try again!<br/>';
if(empty($email_1)) $ERRmsg .= 'You did not enter a Email. Please go back and try again!<br/>';
if(empty($email_2)) $ERRmsg .= 'You did not re-enter you Email. Please go back and try again!<br/>';
if(empty($username)) $ERRmsg .= 'You did not enter a Username. Please go back and try again!<br/>';
if(empty($password_1)) $ERRmsg .= 'You did not enter a password! Please go back and try again!<br/>';
if(empty($jed)) $ERRmsg .= 'You did not choose a Jednostka! Please go back and try again!<br/>';
if(empty($dob)) $ERRmsg .= 'You did not enter a Date of Birth! Please go back and try again!<br/>';
if(empty($stopien)) $ERRmsg .= 'You did not choose a Stopien! Please go back and try again!<br/>';
if(empty($funk)) $ERRmsg .= 'You did not enter a Funkcjia! Please go back and try again!<br/>';
if($email_1 !== $email_2) $ERRmsg .= 'Your emails did not match! Please go back and try again!<br/>';
//Checks to see if error message is empty, if empty does rest of code
if(empty($ERRmsg))
{
//pick databases and tables
//creates query for warta database
$wdp_insert = "
INSERT INTO Users_tbl (
`ID`,
`F_NAME`,
`L_Name`,
`P_number1`,
`P_number2`,
`Address`,
`City`,
`State`,
`Zip`,
`Email`,
`username`,
`password`,
`Jednostka`,
`Funkcjia`,
`High`,
`Active`,
`user_registered`,
`user_email`,
`user_login`,
`user_pass`,
`user_nicename`,
`display_name`,
`groupID`,
`prefs_list_item`
)VALUES(
'',
'$first_name',
'$last_name',
'$phone_number_1',
'$phone_number_2',
'$address',
'$city',
'$state',
'$zip_code',
'$email_1',
'$username',
'$password',
'$jed',
'$funk',
'$jed',
'0',
'',
'$email_1',
'$username',
'$password',
CONCAT('$First_name', ' ', '$Last_name'),
CONCAT(;$First_name', ' ', '$Last_name'),
'',
''
)
";
//excutes the insert
$exec = mysql_query($wpd_insert, $wdp_select) or die ("<p>Sorry, there was an unrecoverable Warta database error. Debug data has been logged.</p>" .mysql_error());
echo ("Written into Database");
//creates a query for Picture database
}
else {
echo ($first_name .' '. $ERRmsg);
exit;
}
?>
what am I missing here.