regalnites Posted March 10, 2006 Share Posted March 10, 2006 Hi all - I'm attempting to build a form for work, using the following code:<?phpfunction GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];}if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "changes")) { $insertSQL = sprintf("INSERT INTO flight_ops_crj_sys_manual (duty_title, acknow_of, manual_number, personnel, personnel_tba, completion_time, comments) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($HTTP_POST_VARS['duty'], "text"), GetSQLValueString($HTTP_POST_VARS['akno'], "text"), GetSQLValueString($HTTP_POST_VARS['manualnum'], "int"), GetSQLValueString($HTTP_POST_VARS['personnel'], "int"), GetSQLValueString($HTTP_POST_VARS['personneltba'], "int"), GetSQLValueString($HTTP_POST_VARS['completetime'], "text"), GetSQLValueString($HTTP_POST_VARS['comments'], "text")); mysql_select_db($database_acknowledge, $acknowledge); $Result1 = mysql_query($insertSQL, $acknowledge) or die(mysql_error()); $insertGoTo = "/forms/change_acknowledgement_complete.php"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo));}?>[b]I'm using a basic DMX insert record behavior, which Ive used several times in the past without errors, so I'm a little perplexed. The action for my form's[/b]action="<?php echo $editFormAction; ?>"[b]and the error message I receive upon submission of the form is:[/b]Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource - for both lines 49 & 50 of the script.[b]Lines 49 and 50 of the script are:[/b]mysql_select_db($database_acknowledge, $acknowledge); $Result1 = mysql_query($insertSQL, $acknowledge) or die(mysql_error());I'd thoroughly appreciate any insight possible. I'm all about learning something new, so I'd love for someone to break it down for me b/c I'm at my wit's end. Thanks for your time, and I look forward to hearing from you. Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 10, 2006 Share Posted March 10, 2006 Unless you have other code we're not seeing, neither $database_acknowledge nor $acknowledge are defined anywhere in the script. Quote Link to comment Share on other sites More sharing options...
regalnites Posted March 10, 2006 Author Share Posted March 10, 2006 [!--quoteo(post=353743:date=Mar 10 2006, 06:06 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 10 2006, 06:06 PM) [snapback]353743[/snapback][/div][div class=\'quotemain\'][!--quotec--]Unless you have other code we're not seeing, neither $database_acknowledge nor $acknowledge are defined anywhere in the script.[/quote]My apologies - the acknowledge.php file holds the connection information for the DB, and the info. within that file are:<?php# FileName="Connection_php_mysql.htm"# Type="MYSQL"# HTTP="true"$hostname_acknowledge = "localhost";$database_acknowledge = "xxx";$username_acknowledge = "xxx";$password_acknowledge = "xxx";$acknowledge = mysql_pconnect($hostname_acknowledge, $username_acknowledge, $password_acknowledge) or die(mysql_error());?> Quote Link to comment 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.