SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why does this SELECT not work?

    Hey,

    I keep getting an error with this select query:-

    PHP Code:
                $catsql "SELECT 
                tbl_categories.cat_id, tbl_categories.cat_name, tbl_cat_selection.cat_id, tbl_cat_selection.selection_id 
                FROM tbl_categories, tbl_cat_selection
                WHERE tbl_categories.cat_id = tbl_cat_selection.cat_id 
                AND tbl_categories.selection_id = "
    .$_GET['sel_id']."";
                
                
    $result mysql_query($catsql) or mysql_error();
                            
                
    $row mysql_fetch_array($result); 
    the error is:-

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /domains/ringspun.co.uk/http/mens-admin/edit-mens.php on line 398

  2. #2
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $result mysql_query($catsql) or die(mysql_error()); 

  3. #3
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about this:

    PHP Code:
    $catsql "SELECT tbl_categories.cat_id, tbl_categories.cat_name, tbl_cat_selection.cat_id, tbl_cat_selection.selection_id, tbl_categories.selection_id
    FROM tbl_categories, tbl_cat_selection WHERE tbl_categories.cat_id = tbl_cat_selection.cat_id AND tbl_categories.selection_id = "
    .$_GET['sel_id']."";
    $result mysql_query($catsql) or mysql_error();
    $row mysql_fetch_array($result); 

  4. #4
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry guys,

    It was my error. I had the wrong field in the WHERE clause

    But thanks anyway.

    Regards

  5. #5
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by billy_111 View Post
    Sorry guys,

    It was my error. I had the wrong field in the WHERE clause

    But thanks anyway.

    Regards
    Yup, i know and thats why i put the column in select, I thought you miss the column to select it. But as you said it was clause problem. So problem solved.

    PHP Code:
    SELECT tbl_categories.cat_idtbl_categories.cat_nametbl_cat_selection.cat_idtbl_cat_selection.selection_idtbl_categories.selection_id FROM tbl_categoriestbl_cat_selection 


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
  •