470,612 Members | 2,271 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

writing a session value to file


windows xp, apache, php and my sql and dreamweaver mx

I have the code below. And it does'nt work! Basically the code below
is the workings behind the scene that inserts a record to a table and it
gets most of it's value from a form. There's alot more to the code such
as the bindings to text boxes etc but I don't think I need to show you
that, just the basics.

Most of the values come from text box bindings but one of them is a
hidden value $custid Basically a user has logged in prior to the insert
page and then I set a session with their userid. When they then want to
insert a record I don't insert the userid but the customer id ($custid)
and I have a bit of code that supposedly grabs the custid from a
customers table doing a join on the userid.

The insert code below works but it writes back nothing to the custid
field in the table. The code below is a combination of dreamweaver mx
generated code and my hand code.

Any idea?



if ($_SESSION[loggedin] != "yes") {
exit; }
// this bit gets the custid from the cutomers table and assigns it to
the variable $thecustid
$thecustid = "SELECT custid FROM customers WHERE userid='" .
$_SESSION['MM_Username'] . "'";
// dreamweaver created all this
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) :

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'"
: "NULL";
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue :
return $theValue;

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

// below is all the insert code, note how I have $custid but nothing is
written back even though I have set it above
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmaddsw")) {
$insertSQL = sprintf("INSERT INTO software (title, shortdesc, `desc`,
version, minreqs, wareid, catid, hpage, dllink, dlsize, triallength,
price, keywords, submitdate, submittime, liveyn, custid) VALUES (%s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, current_date(),
current_time, 'N', '$thecustid')",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['shortdesc'], "text"),
GetSQLValueString($_POST['desc'], "text"),
GetSQLValueString($_POST['version'], "text"),
GetSQLValueString($_POST['minreqs'], "text"),
GetSQLValueString($_POST['wareid'], "int"),
GetSQLValueString($_POST['catid'], "int"),
GetSQLValueString($_POST['hpage'], "text"),
GetSQLValueString($_POST['dllink'], "text"),
GetSQLValueString($_POST['dlsize'], "text"),
GetSQLValueString($_POST['triallength'], "text"),
GetSQLValueString($_POST['price'], "double"),
GetSQLValueString($_POST['keywords'], "text"));

mysql_select_db($database_local, $local);
$Result1 = mysql_query($insertSQL, $local) or die(mysql_error());
Jul 17 '05 #1
0 1104

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

27 posts views Thread by mrbog | last post: by
1 post views Thread by mudge | last post: by
20 posts views Thread by Brian Burgess | last post: by
3 posts views Thread by Geoff Winsor | last post: by
11 posts views Thread by Vishal | last post: by
2 posts views Thread by lookee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.