Thread: PHP/MySQL

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    PHP/MySQL


    need help in getting data from a mysql column that contains slashes - the error states that Unknown column 'bur' in 'where clause' - bur is actually the first set of characters before the first slash.

    Please help
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    Please post the code you have trouble with.

    When posting code, use the [code ] [ /code] tag to keep the format.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0
    [code ]

    $matric_no=addslashes(trim(strip_tags($_POST['matric_no'])));


    //check if student has already registered


    $querya ="select * from pers_data where matric_no =

    $matric_no";
    $resulta = mysql_query($querya) or die(mysql_error());
    $numrowa = mysql_num_rows($resulta);
    if(mysql_num_rows($resulta) > 0){

    //you have already registered, please go ahead and pay (part

    of) your fees'

    include('payfees.php');

    exit;
    }


    [ /code]
  6. #4
  7. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,614
    Rep Power
    1945
    Forgot to say you should remove the spaces in the code tags.

    How does $querya look like if you print/echo it out?

    (If you want to prevent a flame war ,) you should not use mysql_query but instead change it to mysqli_query or PDO.
    I recommend you look up SQL Injection, especially if you don't know about it.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    Nothing here defines this 'bur' you speak of enough for us to help. It appears it will be held within your $matric_no. Can you provide us its echo?

    And I'm sure it will get noted anyway, but perhaps your next step of research should be switching to MySQLi or PDO and using Prepared Statements. mysql_ is deprecated and soon to be non-existent/non-functioning when it is no longer suppoerted by PHP.
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him

IMN logo majestic logo threadwatch logo seochat tools logo