SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sql query outputs different in IE and NS

    I have a strange problem where the output of a query is different in Internet Explorer and Netscape Communicator --- it works fine in Netscape 6.

    Here's the query:

    $sql="SELECT h.*, a.agentname, a.agenturl, a.use_header FROM homes h, agents a WHERE (a.id='$current_user') AND (h.owner=a.id) ORDER BY h.id $limit_str";

    $limit_str is determined based on the number of results from a counter query.

    For my test data, 3 records should display -- they all work fine in IE 4+ and Netscape 3 & 6.* but only 1 of them shows up in Netscape Communicator. It only shows the last record. Also, I can't view the page source in Communicator while I can with the other browsers.

    Am I doing something wrong?? I checked the validity of the code with HomeSite's validation system and it was basically spotless - so it can't be the html.

    Any ideas into this strange problem are appreciated
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net

  2. #2
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The SQL query happens server-side, not in the browser. The fact that your query appears to be fine in most browsers means that your query is not the problem. Most likely the problem is with the code that output the query to the web page.

    Try posting your code for more help.

  3. #3
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the query directly at mysql command prompt to find out how many rows are returned.

    Also in the query you need to use AS,

    $sql="SELECT h.*, a.agentname, a.agenturl, a.use_header FROM homes AS h, agents AS a WHERE (a.id='$current_user') AND (h.owner=a.id) ORDER BY h.id $limit_str";

    Paul

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats not accurate, you do not need an AS when aliasing tables. I am 99% sure its a missing table tag thats the only reason I can figure it would work in the others and not ns4.* since its the only one that really complains about that sort of thing.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp
    Thats not accurate, you do not need an AS when aliasing tables. I am 99% sure its a missing table tag thats the only reason I can figure it would work in the others and not ns4.* since its the only one that really complains about that sort of thing.
    Freddy I'm pretty sure it is, at least I've read it in the MYsql manual. Do you have any references (I'd love to get more information, thanks)?

    Paul

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you just run a query in MySQL one with AS in there and one without, you'll see you get the same results.

    BTW I wasn't saying your way is wrong, just that it isn't the problem. AS they both produce the same result.

    From the MySQL Manual
    Code:
    A table reference may be aliased using tbl_name [AS] alias_name: 
    mysql> select t1.name, t2.salary from employee AS t1, info AS t2
               where t1.name = t2.name;
    mysql> select t1.name, t2.salary from employee t1, info t2
               where t1.name = t2.name;

    http://mysql.he.net/documentation/my...ce.html#SELECT
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see, thanks.

    BTW I wasn't saying your way is wrong, just that it isn't the problem. AS they both produce the same result.
    Yea, you're right, but we don't know exactly how's formatted the information (maybe include HTML code)?

    Sound to me like a HTML compatibility problem between NN and IE.

    Paul
    Last edited by Paul S; Sep 17, 2001 at 17:26.

  8. #8
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that and the fact that IE and NS6 worked and Navigator didn't is more proof that it's probably the outputted html that's your culprit.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  9. #9
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've checked and re-checked my html code, ran it through multiple code checking programs and they all come up with no errors. The really strange thing is that Netscape 4 won't let me view the source to check the outputted code -- only NS6 and IE will let me. And only 1 of the tables is shown in NS4 while 3 are shown in the other browsers... its mind boggling.

    I just ran the query in telnet and it came up with 3 results as expected.

    As requested by several people in this thread, here is the code for the troublesome area. Its kindof long.

    PHP Code:
    $result mysql_query("SELECT * FROM homes WHERE owner = '$current_user'");
    $num_rows mysql_num_rows($result);

    print 
    "<table border=0 cellspacing=0 cellpadding=2 width=650>";
    print 
    "<tr bgcolor=\"#eeeeee\"><td valign=top align=left><span class=heading>Manage Properties</span><br><span class=standard>Only the first property image is displayed on this page.</span></td>";
    print 
    "<td valign=top align=left><span class=standard>There are currently <b>$num_rows</b> properties listed<br>";

    if (
    $cur_page == "") {$cur_page 0;}
    $page_num $cur_page 1;
    $total_num_page ceil($num_rows/$properties_per_page);

    if (
    $total_num_page != 0) {
    print 
    "This is page <b>$page_num</b> of <b>$total_num_page</b><br>";
    $prevpage $cur_page-1;
    $nextpage $cur_page+1;
    if (
    $page_num != 1){print "<a href=\"index.php?sessid=$sessid&cur_page=$prevpage\">Previous Page</a>";}
    if (
    $page_num != $total_num_page){print "  <a href=\"index.php?sessid=$sessid&cur_page=$nextpage\">Next Page</a>";}
    }
    print 
    "</span></td></tr></table>";

    $limit_str "LIMIT "$cur_page $properties_per_page .",$properties_per_page";

    $sql="SELECT h.*, a.agentname, a.agenturl, a.use_header FROM homes h, agents a WHERE (a.id='$current_user') AND (h.owner=a.id) ORDER BY h.id $limit_str";
    $result mysql_query($sql);

    while (
    $a_row =mysql_fetch_array ($result)) {
    extract($a_row);

    print 
    "<p><table width=650 border=0 cellpadding=3 cellspacing=0>";
    print 
    "<tr bgcolor=\"black\"><td valign=top align=left width=150><a class=heavywhite href=\"$link\" target=new>Listing ID: $id</a>\n";
    if (
    $mls) { print "<br><a class=heavywhite href=\"$link\" target=new>MLS #: $mls</a>";}
    print 
    "</td><td valign=top align=left bgcolor=\"#CCCCCC\" width=310><span class=standard>";
    if (
    $title) { print "<b>Title:</b> $title<br>\n";}
    if ((
    $address) || ($city)) { print "<b>Address:</b> $address $city";}
    print 
    "</span></td><td width=120 valign=top align=left bgcolor=\"#CCCCCC\"><span class=standard>\n";
    if ((
    $a_level 0) && ($listings <=$count)) {
    print 
    "<img src=\"$config[root_path]$config[images]edit.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Modify Listing $id\">&nbsp;<a href=\"index.php?sessid=$sessid&edit=$id\">Modify Listing</a><br>";
    }
    print 
    "<img src=\"$config[root_path]$config[images]delete.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"Delete Listing $id\">&nbsp;<a href=\"index.php?sessid=$sessid&delete=$id\" onclick=\"return ConfirmDelete()\">Delete Listing</a>";
    print 
    "</span></td></tr>";
    print 
    "<tr><td align=center valign=top>";
    print 
    "image info here";
    print 
    "</td><td valign=top align=left colspan=2><span class=standardb>Description</span><br><span class=standard>$previewdesc</span></td></tr>";
        print 
    "</table>\n";

    I've been hard-coding my html for years and this is the first time that I've been stumped.

    Thanks to everyone for your ideas!
    Last edited by jdulberg; Sep 18, 2001 at 12:21.
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net

  10. #10
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps this is the problem:
    PHP Code:
    print "<tr><td valign=top align=left colspan=2><span class=standardb>Description</span><br><span class=standard>$previewdesc</span></td></tr>"
    colspan should equal 3 not 2.

  11. #11
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for checking my code... it seems that I left out 1 line from the html so a <td></td> is missing from there. I have edited the code to fix the colspan issue. That was a good spotting and I wish it were the answer but it was just my copy/paste mistake.

    Thanks again.
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net

  12. #12
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jdulberg, NN is really strict with table syntax, if you made a mistake then it refuses to show anything.

    Try this, copy the html code from IE (if you cannot get it with NN maybe you are requesting the page via POST method), and write it here. That way is more easy to search the problem.

    Paul

  13. #13
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also if you provided a link to where we could see this online, it may help to figure out whats going on.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  14. #14
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    eureka!! It was a missing </table>!

    When I pasted the code into my code editor and went through it line by line, I noticed that the closing table wasn't being printed for some reason. I stuck it on its own print ""; line and now it works fine. Stupid Netscape and its strict code.

    Ah well... so thanks to everyone who had the time to check out my problem. I'm now in the process of adding a browser detector that'll tell the users to update their browsers!

    thanks again!
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •