Jump to content

Recommended Posts

Hello.  I'm very new to php but I'm coming along slowly.  I have a problem with a page.  Now in my database i have say these fields

firstname, lastname, address and username

 

I am trying to create a session variable based on the username so the person viewing the page only sees their details and no one Else's!  I have written the query myself but I have used dreamweaver to do the logging in to the page.  Everything seems to work but i keep getting this error

 

  Fatal error: Call to undefined function: getsqlvaluestring()

 

The line seems to be referring to something in this code;

 

<?php
mysql_select_db($database_newconnection, $newconnection);

$FullRec__query=sprintf("SELECT * FROM Members WHERE Username=%s",
    GetSQLValueString($_SESSION['MM_Username'], "text")); 
   
  $FullRec = mysql_query($FullRec__query, $newconnection) or die(mysql_error());

  $FullRecArray = mysql_fetch_array($FullRec);


?>

 

For a view of the full code here is it!  I am sorry I know its very messy as dreamweaver sucks at php!

 

<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}


// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);

  $logoutGoTo = "thankyou.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php include('Connections/newconnection.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "2,3";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
mysql_select_db($database_newconnection, $newconnection);

$FullRec__query=sprintf("SELECT * FROM Members WHERE Username=%s",
    GetSQLValueString($_SESSION['MM_Username'], "text")); 
   
  $FullRec = mysql_query($FullRec__query, $newconnection) or die(mysql_error());

  $FullRecArray = mysql_fetch_array($FullRec);


?>

 

Can anybody please help.  The funny thing is this code was working fine then Changed something in Dreamweaver and it all went wrong!!!  I've been staring at the code too long now so I cant seem to see anything!!

Link to comment
https://forums.phpfreaks.com/topic/144604-displaying-a-field-from-a-database/
Share on other sites

This line:

 

GetSQLValueString($_SESSION['MM_Username'], "text")

 

calls a function (GetSQLValueString), but i can't see it being defined anywhere in your code below, it may be in one of your included files, but the error you are getting suggests that you have not made that function visible to the page in your second piece of code

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.