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
https://forums.phpfreaks.com/topic/101146-ampersand-problem/
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
https://forums.phpfreaks.com/topic/101146-ampersand-problem/#findComment-517374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.