|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-07-17 19:34 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 10:00:02 2025 UTC |
function idses(){ $email=$_SESSION["email"]; mysql_error($uti=mysql_query("SELECT id,email FROM player WHERE email='$email'")); $linhauti=mysql_fetch_array($uti); $user=$linhauti["id"]; };