Jump to content

Recommended Posts

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

[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.

Link to comment
https://forums.phpfreaks.com/topic/4639-it-should-work/
Share on other sites

[!--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());
?>
Link to comment
https://forums.phpfreaks.com/topic/4639-it-should-work/#findComment-16254
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.