Re: Insert Record (php.ini)
| From: | Edson Waite | Date: | Thu, 26 Dec 2002 05:21:37 +0000 |
| Subject: | Re: Insert Record (php.ini) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129341@lists.php.net to get a copy of this message | ||
I checked and register_globals is ON, I am new to php and I am building on a
tutorial from a book. below is the code any help would be appeciated.
Thank you,
Ed Waite
<?php
phpinfo();
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"]
== "Contribution")) {
$insertSQL = sprintf("INSERT INTO stories (firstName, lastName, address1,
address2, city,
state, country, postCode, telephone, email, title, story)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['firstName'],
"text"),
GetSQLValueString($HTTP_POST_VARS['lastName'],
"text"),
GetSQLValueString($HTTP_POST_VARS['address1'],
"text"),
GetSQLValueString($HTTP_POST_VARS['address2'],
"text"),
GetSQLValueString($HTTP_POST_VARS['city'], "text"),
GetSQLValueString($HTTP_POST_VARS['state'], "text"),
GetSQLValueString($HTTP_POST_VARS['country'],
"text"),
GetSQLValueString($HTTP_POST_VARS['postCode'],
"text"),
GetSQLValueString($HTTP_POST_VARS['telephone'],
"text"),
GetSQLValueString($HTTP_POST_VARS['email'], "text"),
GetSQLValueString($HTTP_POST_VARS['title'], "text"),
GetSQLValueString($HTTP_POST_VARS['story'], "text"));
mysql_select_db($database_afm, $afm);
$Result1 = mysql_query($insertSQL, $afm) or die(mysql_error());
$insertGoTo = "process_story.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
"John W. Holmes" <holmes072000@charter.net> wrote in message
news:000401c2ac90$8a2f77f0$7c02a8c0@coconut...
> > I am trying to create a form to insert records into a MySQL db what
> > setting
> > should I be looking at in the php.ini? My page seems to work and goes
> to
> > the
> > next page correctly without errors, but does not enter any information
> in
> > the database.
>
> Probably register_globals, if I had to guess. Otherwise, show your code
> so we can see what's going on.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>