Jump to content


Photo

It should work?


  • Please log in to reply
2 replies to this topic

#1 regalnites

regalnites
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 March 2006 - 10:02 PM

Hi all - I'm attempting to build a form for work, using the following code:

<?php
function 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));
}
?>

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

action="<?php echo $editFormAction; ?>"

and the error message I receive upon submission of the form is:

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource - for both lines 49 & 50 of the script.

Lines 49 and 50 of the script are:

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.



#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 March 2006 - 10:06 PM

Unless you have other code we're not seeing, neither $database_acknowledge nor $acknowledge are defined anywhere in the script.
Legend has it that reading the manual never killed anyone.
My site

#3 regalnites

regalnites
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 March 2006 - 10:34 PM

[!--quoteo(post=353743:date=Mar 10 2006, 06:06 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Mar 10 2006, 06:06 PM) View Post[/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());
?>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users