Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2006
    Thanked 0 Times in 0 Posts

    help to understand this code

    $query = "INSERT INTO `person` VALUES ('', '$title', '$content', '$submission', '$web', '$person', '$email', '$tele', '$address', '', '$type')";
    @$result=mysql_query($query,$link) or die("no connection on insert");

    could someone explain about this code. query is use to search. is INSERT INTO 'person' that what has been found is inseted to a new table? values are those fields of some tables? what about this line:
    @$result=mysql_query($query,$link) or die("no connection on insert");

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Thanked 36 Times in 35 Posts
    everything after 'VALUES' is a value (!) that is being inserted into the person table of a database- the names of the variables seem pretty self explanatory, but listing the column names (in brackets, before VALUES) is generally a good idea.
    The first line is assigning the string containing the sql to the variable $query, and the second line is sending it to the database. The @ suppresses error messages (not a good thing on code that you don't understand...) and the 'or die(' bit means that should the query fail, then the error message will be shown (the text given is a little misleading as there are a number of other reasons why it might fail...).

    You seem to think this has something to do with searching, which seems unlikely to me based on the fieldnames, but some context to the code (what application it's from? what the filename is called? the function name if it's within one? some code that precedes that you've given?) would all help.


    Posting Permissions

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