#45548 [Opn->Bgs]: Fetch_array not working on function Warning: mysql_fetch_array():suppli

From: Date: Thu, 17 Jul 2008 19:38:29 +0000
Subject: #45548 [Opn->Bgs]: Fetch_array not working on function Warning: mysql_fetch_array():suppli
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126907@lists.php.net to get a copy of this message
ID: 45548 Updated by: felipe@php.net Reported By: deathmachine-pt- at hotmail dot com -Status: Open +Status: Bogus Bug Type: MySQL related Operating System: windows xp PHP Version: 5.2.6 New Comment: Use mysql_error() to know the error. Previous Comments: ------------------------------------------------------------------------ [2008-07-17 19:34:51] deathmachine-pt- at hotmail dot com Description: ------------ Im using dreamweaver 8 php Im getting this same error on everytime i call a function with fetch array i have try so much times to solve it and had no luck i have the following function: function connect(){ mysql_connect("localhost","eensino_artur","deathmachine90"); mysql_select_db("eensino_patartur"); }; function idses(){ $email=$_SESSION["email"]; $uti=mysql_query("SELECT id,email FROM player WHERE email='$email'"); $linhauti=mysql_fetch_array($uti); $user=$linhauti["id"]; }; the connect function works but when i call the idses(); it gives me the following warning Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ... if i do this : $email=$_SESSION["email"]; $uti=mysql_query("SELECT id,email FROM player WHERE email='$email'"); $linhauti=mysql_fetch_array($uti); $user=$linhauti["id"]; as you see i use no function , it works 100% if i do the select on phpmyadmin mysql SELECT id,email FROM player WHERE email='death@hotmail.com'; it works and selects the id. if i add to the function return $user; it doesnt work also im using phpMyAdmin - 2.10.1 and MySQL client version: 5.0.51a. Why does the fetch_array without function works on php and does not if i call it as a function even creating the same function on the php page im using it reproduces the same warning. What is the solution for this? Reproduce code: --------------- <?php function connect(){ mysql_connect("localhost","eensino_artur","deathmachine90"); mysql_select_db("eensino_patartur"); }; function idses(){ $email=$_SESSION["email"]; $uti=mysql_query("SELECT id,email FROM player WHERE email='$email'"); $linhauti=mysql_fetch_array($uti); $user=$linhauti["id"]; }; echo $user; also <?php connect(); idses(); echo $user; ?> Expected result: ---------------- echo of the mysql selection id using a session email Actual result: -------------- Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45548&edit=1

« previous php.bugs (#126907) next »