php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45548 Fetch_array not working on function Warning: mysql_fetch_array():suppli
Submitted: 2008-07-17 19:34 UTC Modified: 2008-07-17 19:45 UTC
From: deathmachine-pt- at hotmail dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 5.2.6 OS: windows xp
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: deathmachine-pt- at hotmail dot com
New email:
PHP Version: OS:

 

 [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 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-17 19:38 UTC] felipe@php.net
Use mysql_error() to know the error.
 [2008-07-17 19:42 UTC] deathmachine-pt- at hotmail dot com
Warning: mysql_error(): supplied resource is not a valid MySQL-Link resource in /home/eensino/public_html/pat/artur/Projecto/functions.php on line 9
 [2008-07-17 19:43 UTC] deathmachine-pt- at hotmail dot com
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"];
};
 [2008-07-17 19:45 UTC] felipe@php.net
Your code is wrong. Read about the parameter in:
http://docs.php.net/mysql-error
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 12:01:31 2025 UTC