PhotoPlog

PhotoPlog (http://www.photoplog.com/forum/index.php)
-   Miscellaneous Foobar (http://www.photoplog.com/forum/forumdisplay.php?f=4)
-   -   Query doesn't work? (http://www.photoplog.com/forum/showthread.php?t=1335)

luker 06-23-2007 06:21 PM

Query doesn't work?
 
Whenever a username ($Name) has spaces in it, this query doesn't work.
Code:

        SELECT userid, filename, username
        FROM photoplog_fileuploads
        WHERE moderate = 0
        AND username = '" . mysql_real_escape_string(htmlspecialchars($Name)) . "'
        ORDER BY RAND()
        LIMIT 5

Is there a way to fix this?

Morgan 06-23-2007 06:59 PM

Check whether the space in $Name is a + or %20 or whatever, and then consider the PHP str_replace function.

luker 06-23-2007 07:09 PM

I took a look at the database and the source and it appears as a space, so I tried this
Code:

        SELECT userid, filename, username
        FROM photoplog_fileuploads
        WHERE moderate = 0
        AND username = '" . str_replace('%20',' ',mysql_real_escape_string(htmlspecialchars($Name))) . "'
        ORDER BY RAND()
        LIMIT 5

nothing...

Morgan 06-23-2007 07:40 PM

Code:

echo $Name;

luker 06-23-2007 09:56 PM

when I view the source, this is what I get
Code:

Jamie Ann

Morgan 06-23-2007 10:12 PM

Check whether 'Jamie Ann' has actually uploaded any files. If so:
Code:

echo mysql_real_escape_string(htmlspecialchars($Name));
You need to find where the space is being treated differently.

luker 06-23-2007 10:39 PM

when I use that, all i get is Jamie Ann

Morgan 06-23-2007 10:45 PM

Without seeing all of your code, all I can do is guess, so consider getting a programmer to look at your code. Please note though that I'm not available for any freelance work at this time, so I'm sorry, but I won't review your code. If you want to upload your code, not any PhotoPlog code, in the hopes that someone else will look at it, feel free.


All times are GMT. The time now is 01:57 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.