Jump to content

Ampersand problem


bad_gui

Recommended Posts

I'm modifying someone else code.  It's a journal article DB that grabs descriptive info from a public database and

inserts it into a mysql DB and associates the pdf file with the entry.

 

I can upload a paper from the journal  Protein engineering, design & selection  without a problem.  I can see the

entry using the php scripts "search" and "browse" functions EXCEPT for one which is "browse by journal"

I can see the journal name listed but when I click it says "no hits"

 

I'm learning php so I'd appreciate it if someone could point me in the right direction.

 

Basically when the user sees a list of journals produced by scanning the DB a producing a list of all unique entries

in the journal column, the user can click on the journal name and get a list of all the articles from that journal.

 

When I click on the journal name I get this link in the browser:

http://192.168.1.99/librarian/index.php?action=browse&select=all&browseby=journal&journal=Protein engineering, design & selection&show=brief&orderby=journal

Here is the relevant code (I think) to produce the listing of journals:

print " <A HREF=\"index.php?action=browse&select=$_GET[select]&browseby=$_GET[browseby]&$_GET[browseby]=$paper[0]&show=brief&orderby=$_GET[browseby]\">
         $paper[0]</A> ($paper[1])<BR>";

 

 

Here is the code (I think) that actually scans the DB

if (!empty($_GET["browseby"])) {
    $browseby_string="WHERE $_GET[browseby]='".$_GET{$_GET['browseby']}."'";
    if ($_GET[browseby] == 'category') $browseby_string="WHERE category REGEXP '(^|[|])".$_GET{$_GET['browseby']}."([|]|$)'";
    $chain = "$_GET[browseby]=".$_GET{$_GET["browseby"]}."&";
    } else {
    $browseby_string='';
    $chain = '';
    }

    if (substr($_GET["select"], -4) == '.pdf') {
    $query = "SELECT * FROM library WHERE file='$_GET[select]'";
    } else {
    $query = "SELECT * FROM library $browseby_string ORDER BY $orderby_string $ordering LIMIT $from,20";
    }
    $result = @mysql_query ($query);
    $rows = @mysql_num_rows($result);
    @mysql_close($link);

 

So is the problem is that

    $browseby_string="WHERE $_GET[browseby]='".$_GET{$_GET['browseby']}."'";

 

can't recognize the string  Protein engineering, design & selection

Do I just mysql_escape_string this?

Link to comment
Share on other sites

Sorry,  I'm just learning.

 

I tried

 


print " <A HREF=\"index.php?action=browse&select=$_GET[select]&browseby=$_GET[browseby]&$_GET[browseby]=urlencode($paper[0])&show=brief&orderby=$_GET[browseby]\">
         $paper[0]</A> ($paper[1])<BR>";

 

But this gives

 

 

urlencode(Protein engineering, design

 

NO HITS

 

 

I also tried single quotes around the 'urlencode($paper[0])' but that didn't work either.  What am I missing?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.