php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13560 mysql_fetch_object can't return any record
Submitted: 2001-10-05 06:33 UTC Modified: 2001-10-05 23:38 UTC
From: xufa at sina dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.0.6 OS: win2000
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: xufa at sina dot com
New email:
PHP Version: OS:

 

 [2001-10-05 06:33 UTC] xufa at sina dot com
it dosen't return any record when i use mysql_fetch_object to fetch result! 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-05 06:38 UTC] cynic@php.net
not enough info. read bugs-dos-and-donts.php
 [2001-10-05 23:38 UTC] xufa at sina dot com
it dosen't return any record when i use mysql_fetch_object to fetch result! 

$UserName1=$HTTP_POST_VARS["UserName"];
$PassWd1=$HTTP_POST_VARS["Passwd"];

$rst_CommandText="select Passwd,OSKEY from admin where UserName='" . $UserName1 . "'";
$result = mysql_db_query("myforum",$rst_CommandText,$rst_ActiveConnection);
echo mysql_result($result,0,"Passwd");  //work correctly!
$rows = mysql_fetch_object($result);
echo $rows->Passwd;                     //but it dosen't work!!! 
 [2002-11-24 19:19 UTC] acholder at bellsouth dot net
i think i'm having the same problem.  here's some code :)
---------------------------------------------------------
// generate and execute query
$query = "SELECT slug, content, contact, timestamp FROM news WHERE id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

// get resultset as object
$row = mysql_fetch_object($result);

// print details
if ($row)
{
?>
	<p>
	<b><? echo $row->slug; ?></b>
	<p>
	<font size="-1"><? echo nl2br($row->content); ?></font>
	<p>
	<font size="-2">This press release was published on <? echo formatDate($row->timestamp); ?>. For more information, please contact <? echo $row->contact; ?></font>
<?
}
else
{
?>
	<p>
	<font size="-1">That press release could not be located in our database.</font>
<?
}
--------------------------------------------------------
the else block is always executed.  i have used mysql> and verified that there is stuff in the table.  i inserted <? echo $result; ?> into the else block.  curiously, it always printed "Resource id #2", even when this url was used:
--------------------------------------------------------
http://127.0.0.1/test/user/story.php?id=1
--------------------------------------------------------

it doesn't seem likely that this is a bug, but hoped someone could easily make some suggestions for troubleshooting this.  i'm very new at this and didn't know where else to go :)

i'm using php4 and mysql 4.0.1 distributed for windows in foxserv.
 [2002-11-24 19:19 UTC] acholder at bellsouth dot net
on windows XP :)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 15:01:30 2025 UTC