GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Aug-2003, 17:39
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road

Recall table row


Im back.....
OK this is waht I call my table with...
PHP Code:

<?php
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
    
    $date = str_replace(',' , '<br/>' , $row["date"]);
    
    $adate = explode("-",$date);
    $year = $adate[0];
    $month = $adate[1];
    $day = $adate[2];
    $date = $day."-".$month."-".$year;

$short=substr($row['body'],0,60); 


echo("
<table width=100% border=1 cellspacing=0 cellpadding=0 bordercolor=#0000FF >
  <tr> 
    <td class=body_text valign=top align=center width=50%>
      <div align=left><u><b>".$row["title"]."</b></u></div>
    </td>
    <td class=body_text valign=top align=center width=50%>Posted on: $date</td>
  </tr>
  <tr> 
    <td class=body_text valign=top align=center colspan=2 height=26><BR>
      $short</td>
  </tr>
  <tr>
    <td class=body_text valign=top align=center colspan=2> 
      <div align=right><a href=\"/new.php?id=".mysql_result($res,$i,"id")."\" onclick=\"Self(this.href,'name');\">More.............. 
        </a></div>
    </td>
  </tr>
</table>
");
}
?>


But on 1 server its ok but on another it keeps repeating (recalling) the second row. Any idea why??????
  #2  
Old 22-Aug-2003, 21:16
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

mysql_result() issue


When you use the MySQL functions that return the entire row such as mysql_fetch_array() like you have in your sample code above, you should avoid using mysql_result() off the same query result resource.

I remember reading about it once before and I was trying to look for the note again in the MySQL docs but can't seem to find it right now. I will post again if I remember where I read that or if I come across some other information on it later...
  #3  
Old 23-Aug-2003, 03:43
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road
Thanks JDS but I have solved it now
Took me a couple of hours but thats the learning curve.
  #4  
Old 23-Aug-2003, 08:56
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
So what was the issue actually?

I also found the note about mysql_result() finally. I should have looked for it at PHP.net instead of MySQL.com

This is for anyone else finding this thread in the future:
Quote:
Calls to mysql_result() should not be mixed with calls to other functions that deal with the result set. ...more
 
 

Recent GIDBlogA Week in Kuwait by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to retrieve selective results from a table. icsys MySQL / PHP Forum 9 18-Nov-2003 03:31
form in a table cell blelisa Web Design Forum 1 19-Aug-2003 09:14
top of table Charlie Web Design Forum 7 27-Mar-2003 02:21
[Tutorial] MySQL Basics nniehoff MySQL / PHP Forum 15 23-Mar-2003 19:42
table question smoky Web Design Forum 1 05-Jan-2003 02:45

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:37.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.