1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php select ExtractValue

Discussion in 'PHP' started by mero2020, Jan 2, 2016.

  1. #1
    Hi
    when execute this query
    <?php
    $sqlr ="select *
    from biblioitems
    where EXTRACTVALUE( marcxml, \ '//datafield[@tag="520"]/subfield[@code="d"]')='' ";

    give me this error

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\ "//datafield[@tag="520"]/subfield[@code="d"]")=""' at line 4

    any help??
     
    Solved! View solution.
    mero2020, Jan 2, 2016 IP
  2. #2
    Try:

    
    $sqlr ="select * from biblioitems
    where EXTRACTVALUE( marcxml,  '//datafield[@tag=\"520\"]/subfield[@code=\"d\"]')='' ";
    
    Code (markup):
    Basically remove the escape string for single quote which I don't see it needed, and add the needed escape for quotes.
     
    ThePHPMaster, Jan 2, 2016 IP
  3. KangBroke

    KangBroke Notable Member

    Messages:
    1,026
    Likes Received:
    59
    Best Answers:
    4
    Trophy Points:
    265
    #3
    One thing I noticed immediately was this
    marcxml, \ '// <----- This appears to me that you were trying to pass the single quote by putting the \ in front of it.

    Yet near the end you had "d"]')='' "; <------ Here you have the what appears to be ending single quote and there is no \

    In this statement you should try EXTRACTVALUE( marcxml, ''//datafield[@tag="520"]/subfield[@code=\"d\"]'')='' ";

    Thats my guess on this.
     
    KangBroke, Jan 2, 2016 IP
  4. KangBroke

    KangBroke Notable Member

    Messages:
    1,026
    Likes Received:
    59
    Best Answers:
    4
    Trophy Points:
    265
    #4
    Couldn't the OP just double up the single quotes?
     
    KangBroke, Jan 2, 2016 IP
  5. mero2020

    mero2020 Greenhorn

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #5
    Thanks this query works well
     
    mero2020, Jan 2, 2016 IP