SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: ??????

  1. #1
    SitePoint Addict Evan2all's Avatar
    Join Date
    Sep 2004
    Location
    Dhaka, Bangladesh
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ??????

    $query_links = "select l_title,l_desc,l_webadd from links where links.lt_id=(select l_type.lt_id from l_type where lt_title='$title') ";

    can anyone say what is the problem with this code???

    error msg is:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select l_type.lt_id from `l_type` where lt_title='fashion-cloth

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of MySQL are you running?
    Subselect support was not present in 3.xx, which will generate that error.

    Subselects are overkill here, try
    PHP Code:
    $query_links "SELECT l.l_title, l.l_desc, l.l_webadd 
    FROM links l 
        INNER JOIN l_type t ON l.lt_id=t.lt_id
    WHERE t.lt_title='
    $title';"
    ps. where is $title coming from? You should be checking for sql injection. Also it should maybe be t.lt_title LIKE '$title' (should use LIKE instead of =)

  3. #3
    SitePoint Addict Evan2all's Avatar
    Join Date
    Sep 2004
    Location
    Dhaka, Bangladesh
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    working fine in my localhost...... using MySQL 4.1.9

    but problem is in remote server....using mysql 4.0.25-standard

    $query_links = "select l_title,l_desc,l_webadd from links where links.lt_id=(select l_type.lt_id from l_type where l_type.lt_title='$title') ";

    dont know where is the problem......

    $title comming from another page.....it contains link_title like business,fashion etc.......

    is it really necessary to join the tables??? what is the wrong with my query???

    if u can please check: http://www.itvisiononline.com/links.php

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can't do subqueries in mysql 4.0. That feature was not introduced until 4.1. You'll have to rewrite the query with joins as dix was doing.

  5. #5
    SitePoint Zealot logitron's Avatar
    Join Date
    Feb 2006
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MySQL did not support subqueries until version 4.1.x. That is why the query is working fine on your localhost, but not on the server. You're going to either have to upgrade MySQL on the server or redesign your query to not use subqueries. If you are going to redesign your query, don't forget that you always have PHP at your disposal to help you retrieve that information. :-)

    Patrick Smith
    Patrick Smith
    PHP Programmer

  6. #6
    SitePoint Addict Evan2all's Avatar
    Join Date
    Sep 2004
    Location
    Dhaka, Bangladesh
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ooooofffffffffffffffff god......

    what i should do????

    i have to change lot of things now........ its really impossible in Bangladesh to upgrade a setup.......

    i am used to subqueries... dont like this joining.....


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
  •