PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
session_start() //Top of every page
function getID($fname, $lname)
{
//Check for Session ID
if (!$PHPSESSID)
{
session_register("TechID")
}
else if (!$TechID)
{
session_register("TechID")
}
//Db Connection
$connection = mysql_connect ("localhost", $DbUsername, $DbPassword);
mysql_select_db ($DbName, $connection);
//SQL for inserting new Data
$sql = "SELECT TechID from techinfo where FName = '$fName' AND LName = '$lName'";
//Execute Query
mysql_query($sql);
//Assign Value to Session
while ($row = mysql_fetch_array($sql_result)) {
$_SESSION["TechID"] = $row["TechID"];
}
}
?>
I am calling this function from another page, whioch my functions page is included as well, but, I can pull the session ID by not $TechID. Any help would be appriciated.
<?php
session_start(); //Top of every page
function getID($fname, $lname)
{
//Check for Session ID
if (!$PHPSESSID)
{
session_register("TechID")
}
else if (!$TechID)
{
session_register("TechID")
}
//Db Connection
$connection = mysql_connect ("localhost", $DbUsername, $DbPassword);
mysql_select_db ($DbName, $connection);
//SQL for inserting new Data
$sql = "SELECT TechID from techinfo where FName = '$fName' AND LName = '$lName'";
//Execute Query
$sql_result = mysql_query($sql);
//Assign Value to Session
while ($row = mysql_fetch_array($sql_result)) {
$_SESSION["TechID"] = $row["TechID"];
}
}
?>
Just a heads up, don't use session_register() and $_SESSION together - they don't play nice and you generally get fairly buggy results. In fact you shouldn't use session_register() at all (it's deprecated and doesn't work with register_globals off). In your function you can just delete:
Still was not working last night so I will try this when I get home to see if I can make it work. coming from ASP sessions these are bit more difficult to make work it seems.