SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2001
    Location
    North Coast NSW Australia
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Code only works locally

    Hi people
    This function code works locally, but dies when run on remote server

    PHP Code:
    function surnamecaps($name) {  
       if (
    strpbrk($name"'")) {
           
    $dsex=explode("'",$name);
           
    $x=ucwords($dsex[0]);
           
    $y=ucwords($dsex[1]);
           
    $Surn=$x."'".$y;
       }
       else {
           
    $Surn=$name;
       }
    return 
    $Surn;

    Am calling it from here
    PHP Code:
    $SN=trim(ucwords(strtolower(mysql_real_escape_string($_POST["Surname"]))));
       if (
    $SN == NULL) {
           
    $error4="You must enter a Surname";
    else {
           
    $SN=surnamecaps($SN);
       } 
    When run remotely it just displays a blank page.
    What it is doing is to take the name entered and format it correctly
    so if o'reilly, or O'reilly is entered, I want to see O'Reilly
    So i use real_escape to escape the ', then make all lower case, then capitalise
    I have tried using single quotes, and using backslash - it all works on my local machine tho'
    Thanks for any help

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Try raising the error reporting level to see if any notices or warnings are being generated:
    PHP Code:
    error_reporting(E_ALL); 
    Then start adding some debug output to your code to see where it stops working.

  3. #3
    SitePoint Member
    Join Date
    Jun 2001
    Location
    North Coast NSW Australia
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dan
    I tried your suggestion, but it shows no error
    When I put the error reporting into local - it gives me errors about undefined variables - I think this is to do with strict php5, but the remote does not give any errors - just blank screen.
    I guess I'll just have to put up with O'reilly for a while until I figure it out

  4. #4
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It could be you have display_errors off on your web server. This code fixes that:
    PHP Code:
    ini_set('display_errors'true); 
    When you say just displays a blank page, this makes me think the error is someplace else in your code. Why do you feel its in this section in particular?

  5. #5
    SitePoint Member
    Join Date
    Jun 2001
    Location
    North Coast NSW Australia
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I turn off this
    PHP Code:
    else {
           
    $SN=surnamecaps($SN);
       } 
    everything works
    As soon as I use the function
    PHP Code:
    function surnamecaps($name) {  
       if (
    strpbrk($name"'")) {
           
    $dsex=explode("'",$name);
           
    $x=ucwords($dsex[0]);
           
    $y=ucwords($dsex[1]);
           
    $Surn=$x."'".$y;
       }
       else {
           
    $Surn=$name;
       }
    return 
    $Surn;

    nothing seems to happen
    But as I said, it works fine locally
    I should add the function is in my includes file
    Last edited by Bobshankar; Jun 23, 2007 at 20:24. Reason: add to thread


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •