SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    645
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Not really sure yet...

    About two years ago I made a script for my daughter to sell tickets to shows for her dance classes. The users could order tickets online and pay via PayPal. The script is also counting down the remaining number of available seats after payment and the customer gets a receipt in their e-mail with the booking confirmation. Another e-mail is sent to my daughter so she can see who bought the tickets.

    There are only 2 shows a year (one in december and one in the end of May). I'm not sure I remember all the code I wrote, since I did it a while ago and have a lot of other things all the time, so when a project is up and running I kinda forget what I did and move on to the next project.
    But in december some people, not all, had some problem with a page when they return from PayPal and paid their tickets. But for others it worked fine.
    Now the same thing happened to a customer the other day and I have no idea why. The only error code they sent to my daughter was this:
    "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1"

    I haven't looked at my pages and code yet, since I don't have them where I am now. I'm just confused when it works for most people, but some people can use it as it's supposed to.
    So, my question is actually what I would look for or maybe ask the people who get the code. I'm not sure I want to mess around with the code when it's close to a show now and people are buying the tickets.

    Does anyone have clue on what to do or look for here? For me it sounds strange.

    And, I'm not a programmer. I'm just playing around and tend to survive with my scripts most of the time. It's fun.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could be a database connection error. You can always look at the files that are on the host. My first step would be to run the faulty sql query directly in sql with something like phpmyadmin.You also may want to alter the script a little so it sends back more information regarding the error.

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    645
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    How can I alter the script to send more error info? That might be a great idea if it works.

  4. #4
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If some people are getting the error and some are not then I suspect this is down the inormation that is getting passed to this script originally entered by the user.

    We'd really need to see the script, but errors like this can be caused by things like you not properly processing user entries used in the query, for example the name O'Leary will cause an SQL syntax error if not handled right, but THOMAS will pass fine.

    Thats where Id start looking as a first port of call.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2010
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a separate config.php file which defines some constants and functions which potentially all other scripts will use. Then at the start of each of my scripts I include the config.php file.

    config.php
    Code:
    <?php
    
    define('LIVE', TRUE); //is set to false when the site is being tested
    define('EMAIL', 'email@example.com'); //put your email address here
    
    //create function to deal with errors
    function my_error_handler ($errNum, $errMsg, $errFile, $errLine, $errVars) {
    $message = "<p>An error occurred in script '$errFile' on line $errLine: $errMsg\n<br />";
    $message .= "Date/Time: " . date('n-j-Y H:i:s') . "\n<br />";
    $message .= "<p>" . print_r ($errVars, 1) . "</p>\n</p>";
    
    //handle the error depending on whether the site is live or not
    if (!LIVE) { //if the site is not live, display the error message to the screen - useful for debugging
    echo '<div>' . $message . '</div><br />'; 
    
    } else { // else, send the error message to the email address defined above
    mail(EMAIL, 'Site Error!', $message, 'From: email@site.com'); //include an email subject and from address - to identify which site is giving the error 
    if ($e_number != E_NOTICE) { //and display an error message to the user only if the error is more serious than a warning.
    echo '<div class="error">A system error occurred. We apologise for the inconvenience.</div><br />';
    	}
    }
    }//end function declaration
    set_error_handler ('my_error_handler'); //set up the error handler function
    ?>


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
  •