dgnzcn Posted June 28, 2014 Share Posted June 28, 2014 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']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/289310-sessiona-variable-problem/ Share on other sites More sharing options...
Ch0cu3r Posted June 28, 2014 Share Posted June 28, 2014 The error is self explanatory the variable $row_katefori_cek is not defined. Make sure you have spelt the variable name correctly. If you are still unsure, then you need to post more code. Quote Link to comment https://forums.phpfreaks.com/topic/289310-sessiona-variable-problem/#findComment-1483309 Share on other sites More sharing options...
dgnzcn Posted June 30, 2014 Author Share Posted June 30, 2014 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']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/289310-sessiona-variable-problem/#findComment-1483407 Share on other sites More sharing options...
Jacques1 Posted June 30, 2014 Share Posted June 30, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/289310-sessiona-variable-problem/#findComment-1483408 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.