|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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! PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 02:00:01 2025 UTC |
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!!!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.