Results 1 to 3 of 3

Thread: SQL Nightmare

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default Always use quotes!

    Generally I have found that the stuff right before the printed error is USUALLY the real cause, so I look at this:

    WHERE language_id = $this_language_id

    and I see that if $this_language_id is null, which I bet it is, it will throw an error.
    Always a good idea to do this:
    language_id = '$this_language_id'
    ... for one thing, many a hack was done with a quoteless ID. Look up SQL-injection for the gory details.

    Anyway, may I suggest putting this in your toolbox:


    $sql="some query";
    $db=mysql_query($sql);
    $ref = mysql_fetch_row($db);
    if (mysql_error()){
    print mysql_error()."<br>$sql<br>";
    exit();
    }

    Seeing the Actual SQL after an error can usually speed up debugging by thousands!

  2. #2
    andychev's Avatar
    andychev is offline Master Glow Jedi
    Join Date
    Apr 2005
    Location
    Chester, UK
    Posts
    150

    Default

    excellent excellent and excellent! Thaks so much! Often the way you look at something for so long it ends up being something so simple. Exactly what you said, put the $this_language_id in quotes and hey presto all working.

    Thanks so much

    Andy

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12