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 Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,070
    Rep Power
    1965
    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 Specialist (4000 - 4499 posts)

    Join Date
    Oct 2003
    Posts
    4,070
    Rep Power
    1965
    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
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,365
    Rep Power
    24
    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 that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.

IMN logo majestic logo threadwatch logo seochat tools logo