You are here: writing a session value to file « PHP SQL « IT news, forums, messages
writing a session value to file

Posted by toedipper on 10/01/85 11:19

Hello,

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?

Thanks,

td

<?
session_start();
if ($_SESSION[loggedin] != "yes") {
header("Location: http://127.0.0.1/custlogin.php");
exit; }
require_once('Connections/local.php');


// 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) :
$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 = $_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());
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация