Jump to content

sessiona variable problem..


dgnzcn

Recommended Posts

hi,

i try to following codes from mysql "id" value to  "aitlik" session variable but  giving following error .

 

Notice: Undefined variable: row_kategori_cek in /Library/WebServer/Documents/test/cat_menu.php on line 5

 

 

 <?php 
 // this sets variables in the session 
$_SESSION['aitlik'] = $row_kategori_cek['id'];


 echo $_SESSION['aitlik']; 
 ?> 

 

Link to comment
https://forums.phpfreaks.com/topic/289310-sessiona-variable-problem/
Share on other sites

hi thanks for answer.

 

i wanna list all of same aitlik values, but query is emty.

her is my full codes.

 

 

<?php session_start();?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }


  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}


$colname_kategori_cek = "-1";
if (isset($_GET['sayfa'])) {
  $colname_kategori_cek = $_GET['sayfa'];
}
mysql_select_db($database_dene_test, $dene_test);
$aitlik = mysql_real_escape_string($_SESSION['aitlik']);
$query_kategori_cek = sprintf("SELECT * FROM menu_bilgi2 WHERE aitlik = '$aitlik' and  sayfa = %s ORDER BY sira ASC", GetSQLValueString($colname_kategori_cek, "text"));
$kategori_cek = mysql_query($query_kategori_cek, $dene_test) or die(mysql_error());
$row_kategori_cek = mysql_fetch_assoc($kategori_cek);
$totalRows_kategori_cek = mysql_num_rows($kategori_cek);
?>
 <?php 
 // this sets variables in the session 
$_SESSION['aitlik'] = $row_kategori_cek['id'];


 echo $_SESSION['aitlik']; 
 ?> 

Do yourself a favor and stop using the Dreamweaver code generator. It's awful, and you'll never learn PHP from it.

 

The mysql_* functions are also obsolete since more than 10 years and will be removed in one of the next PHP releases. Nowawadys, we use PDO.

 

So instead of spending your time debugging shitty auto-generated code, why don't you learn the language and write your own code? After almost 5 years, it's about time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.