Jump to content

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.

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.