whizzykid Posted July 13, 2012 Share Posted July 13, 2012 I get this error i try to fill this form on my site. Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/cicpriva/public_html/Registration.php on line 62 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/cicpriva/public_html/Registration.php on line 63 <?php require_once('Connections/cicpriva_reg.php'); ?> <?php mysql_select_db($database_cicpriva_reg, $cicpriva_reg); $Result1 = mysql_query($insertSQL, $cicpriva_reg) or die(mysql_error()); And this is my cicpriva_reg.php file $hostname_cicpriva_reg = "localhost"; $database_cicpriva_reg = "cicpriva_reg"; $username_cicpriva_reg = "cicpriva_goto"; $password_cicpriva_reg = ""; $dibby = mysql_pconnect($hostname_cicpriva_reg, $username_cicpriva_reg, $password_cicpriva_reg) or trigger_error(mysql_error(),E_USER_ERROR); ?> Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/ Share on other sites More sharing options...
NomadicJosh Posted July 13, 2012 Share Posted July 13, 2012 Can you post the query you have for $insertSQL? Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361214 Share on other sites More sharing options...
whizzykid Posted July 13, 2012 Author Share Posted July 13, 2012 ok this is it if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO registration (Title, `Last Name`, `First Name`, `Date of Birth`, `Marital Status`, Email, `Mobile Number`, `Phone Number`, Address, `Zip/Postal Code`, Country, `Name of Employeer/Business`, `Address of Employer/Reference`, `Postal Code`, `Nature of Business/Occupation`, `Position_ Held`, `Gross_ Annual _Income`, `House_ Hold_ Income`, `Preferred_Method_of- Payment`, `Preferred_ Account _Type`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['Title'], "text"), GetSQLValueString($_POST['Last_Name'], "text"), GetSQLValueString($_POST['First_Name'], "text"), GetSQLValueString($_POST['Date_of_Birth'], "date"), GetSQLValueString($_POST['Marital_Status'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['Mobile_Number'], "int"), GetSQLValueString($_POST['Phone_Number'], "int"), GetSQLValueString($_POST['Address'], "text"), GetSQLValueString($_POST['ZipPostal_Code'], "int"), GetSQLValueString($_POST['Country'], "text"), GetSQLValueString($_POST['Name_of_EmployeerBusiness'], "text"), GetSQLValueString($_POST['Address_of_EmployerReference'], "text"), GetSQLValueString($_POST['Postal__Code'], "int"), GetSQLValueString($_POST['Nature_of_BusinessOccupation'], "text"), GetSQLValueString($_POST['Position__Held'], "text"), GetSQLValueString($_POST['Gross___Annual__Income'], "int"), GetSQLValueString($_POST['House__Hold__Income'], "int"), GetSQLValueString($_POST['Preferred_Method_of_Payment'], "text"), GetSQLValueString($_POST['Preferred__Account__Type'], "text")); mysql_select_db($database_cicpriva_reg, $cicpriva_reg); $Result1 = mysql_query($insertSQL, $cicpriva_reg) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361221 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2012 Share Posted July 13, 2012 The variable name you are using for the mysql_pconnect link resource isn't the variable you are using in the other mysql statements that expect that link resource. Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361223 Share on other sites More sharing options...
whizzykid Posted July 13, 2012 Author Share Posted July 13, 2012 pls explain better. thanks Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361244 Share on other sites More sharing options...
mikosiko Posted July 13, 2012 Share Posted July 13, 2012 related and complementary answers here http://forums.phpfreaks.com/index.php?topic=362403.0 and http://forums.phpfreaks.com/index.php?topic=362402.0 Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361266 Share on other sites More sharing options...
whizzykid Posted July 13, 2012 Author Share Posted July 13, 2012 related and complementary answers here http://forums.phpfreaks.com/index.php?topic=362403.0 and http://forums.phpfreaks.com/index.php?topic=362402.0 Sorry the topic isnt there anymore. Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361272 Share on other sites More sharing options...
mikosiko Posted July 13, 2012 Share Posted July 13, 2012 both topics were removed by an Admin... one was duplicated of this one and the other no idea why... anyways complementing PfmAbismad answer $dibby = mysql_pconnect($hostname_cicpriva_reg, $username_cicpriva_reg, $password_cicpriva_reg) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database_cicpriva_reg, $cicpriva_reg); $dibby <> $cicpriva_reg and my answer for your second post regarding to your other mysql error for your insert was: the usage of pathname delimiters ('/' and '\') are not allowed in column names... Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361286 Share on other sites More sharing options...
ManiacDan Posted July 13, 2012 Share Posted July 13, 2012 There's a number of things wrong here. First, your thread title is absolutely useless. Use the title to actually describe the problem. Now, to your actual code. Look at the error message: Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/cicpriva/public_html/Registration.php on line 62 mysql_select_db is failing, with the error that the supplied argument is not valid. What argument are you supplying to that function? Let's look: mysql_select_db($database_cicpriva_reg, $cicpriva_reg); So your code believes $cicpriva_reg is the database object. Why isn't that correct? Go look at where you make the database object: $dibby = mysql_pconnect($hostname_cicpriva_reg, $username_cicpriva_reg, $password_cicpriva_reg) or trigger_error(mysql_error(),E_USER_ERROR); As PFMaBiSmAd and mikosiko have both already explained, $dibby is not $cicpriva_reg Your database column names are unusual, but not technically incorrect if this is MySQL. You should try to avoid using special characters like / and \ in your column names, and stick to only letters, numbers, and the underscore character. That ensures interoperability. Quote Link to comment https://forums.phpfreaks.com/topic/265598-urgent-help-needed/#findComment-1361292 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.