Welcome to Geeklog, Anonymous Thursday, November 28 2024 @ 05:33 pm EST

Geeklog Forums

Error when e-mailing stories as anonymous


Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada

I updated from GL 1.3.6 to 1.3.7 today, and an old problem returned. Anonymous users can't e-mail stories.

If an anonymous user tries to e-mail a story, he sees "1064: You have an error in your SQL syntax near '' at line 1" in the web page. The error.log shows "1064: You have an error in your SQL syntax near '' at line 1 SQL in question: SELECT email FROM gl_users WHERE uid =".

I had the same problem with GL 1.3.6, and I made a change to profiles.php as discussed at this story. However, with GL 1.3.7 I get the exact same errors with the unmodified profiles.php and with the modified profiles.php. I'm stumped. Can anyone shed any light here?


Kevin Horton
 Quote

Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada
I created a hybrid version of profiles.php that is the 1.3.6 version of function mailstoryform (as modifed earlier to work for anonymous users) but all the other changes from 1.3.7. All users can e-mail stories now. I'm willing to add debug code to the 1.3.7 version of profiles.php if that will help anyone figure out what is going on. I don't know enough about php and mysql to do anything more than very basic debugging though, unless someone can point me at what to look for.---Kevin
Kevin Horton
 Quote

Anonymous

Anonymous
I'm curious. What is your setup?
 Quote

Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada
Well, my host (phpwebhosting) seems to have gone down, so I can't get any version info right now. But I enabled sendmail on my local test site, and I get the same errors here. On my local site I've got php 4.2.2 and mysql 3.23.51. I'm running Mac OS X 10.1.5 locally, and phpwebhosting is running some variant of unix. The only thing that is even slightly non-standard is that the files that normally would be in public_html are in a directory in public_html. All the paths are set up to up to reflect that, and everything else works correctly, so I don't see how this could be the problem. I'm really baffled by the error message. The SQL query quoted by the error message is in the part of the code that is supposed to be executed if $_USER['username'] is not empty. Well, with an anonymous user, this code shouldn't be running, if I am reading profiles.php correctly. I've been doing my testing by logging out to become an anonymous user. I wondered whether the username could be cached somehow, so I started up another browser that hadn't been run on my local site for weeks, flushed the cache and then tried it. I got the same error.---Kevin
Kevin Horton
 Quote

Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada
phpwebhosting is back up. They've got php 4.2.3 and mysql 3.23.54, for pc-linux (i686). Is they any other config info that might be relevant? ---Kevin
Kevin Horton
 Quote

Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada
Well, it turns out a similar fix to the one I used for GL 1.3.6 works with 1.3.7. I screwed it up the first time, as I didn't completely understand the changes made to profiles.php. But once I figured out how it worked I changed two lines and my problem is solved. Line 212 in the original profiles.php looked like:
Text Formatted Code
    if (empty($_USER['username']) &&
I changed it to:
Text Formatted Code
    if (empty($_USER['uid']) &&
Similarly, I changed line 228 from:
Text Formatted Code
    if (!empty ($_USER['username']))
to:
Text Formatted Code
    if (!empty ($_USER['uid']))
I played around with the original file a bit to try to understand what was happening. I added some debug code right before the sql query on line 229. I stole the debug code idea from Tom Willet (at least I think it was Tom), whose Gallery hack filled my error log full of debug code until I figured out where it was coming from (comment out the call to COM_errorLOG in gallery/init.php if you have been similarly cursed). Debug code:
Text Formatted Code

        // debug code added by KWH
        $errorstring = "User name is ";
        $errorstring .= $_USER['username'];
        COM_errorLOG($errorstring);
        $errorstring2 = "User ID is ";
        $errorstring2 .= $_USER['uid'];
        COM_errorLOG($errorstring2);
        // end of debug code
 
With no one logged in, this gave me error.log entries of:
Text Formatted Code

01/01/03 19:24:05 - User name is Anonymous
01/01/03 19:24:05 - User ID is  
01/01/03 19:24:05 - 1064: You have an error in your SQL syntax near '' at line 1 SQL in question: SELECT email FROM gl_users WHERE uid =  
 
So, the username is not empty if no one is logged in - it is "Anonymous". the UID is empty though. I guess I should do a search for other places where a check of an empty username occurs to see what else might not be working. Question - is my problem with anonymous users not being able to e-mail stories some sort of isolated event, or should I report it as a bug? ---Kevin
Kevin Horton
 Quote

Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada
I obviously have no idea how this
Text Formatted Code
 stuff works.  Maybe I needed to do that in html mode.---Kevin

Kevin Horton
 Quote

Status: offline

rv8

Forum User
Regular Poster
Registered: 10/10/02
Posts: 105
Location:Ottawa, Canada
I've been baffed why I get this problem, but most other users don't. Well, I found a piece of code in my lib-custom.php that probably explains why anonymous users don't have a blank username. The following code is part of the Vistitor Stats Block by Mr.GxBlock of www.gxblock.com. if($_USER["username"] == ""Wink{ $_USER["username"] = "Anonymous"; } I'm not sure who is supporting his stuff now, but the installation instructions should probably have info explaining the problem with anonymous users e-mailing stories, and what changes need to be made to lib-common.php.---Kevin
Kevin Horton
 Quote

Anonymous

Anonymous
Thanks for the setup info. I haven't seen anyone else having the same problems you experienced. That's why I was so curious. I see you narrowed down the source of the problem. Nice job.
 Quote

All times are EST. The time is now 05:33 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content