Page 1 of 1

PHP newbie - need help with ecommerce

Posted: Sat Jan 23, 2010 4:27 pm
by cams
I have inherited the administration of a PHP website. I'm an html guy with a bit of knowledge about php gained from running a phpBB forum, which is to say not very much at all. I understand includes, and I can use Wordpress templates and edit them a little.

So, that's my background. Now here's the problem.

The website has an ecommerce function for purchasing e-tickets for concerts and events. I have generated some fake sales and I'm getting the following error message when I attempt to print a ticket:

Code: Select all

Notice: Undefined variable: eventImage in /home/arralcom/public_html/tickets.php on line 236
The line of code is as follows:

Code: Select all

$pdf->addJpegFromFile($eventImage,250,324,90);
The php page in question is here:

http://www.arranfolkfestival.com/tickets.php

The PDF is generated using a plug-in from here:

http://www.arranfolkfestival.com/class.pdf.php
http://www.ros.co.nz/pdf

I can give access to the page I've generated with the fake sales to download tickets:
http://www.arranfolkfestival.com/cgi-bi ... stival.com

I did an order for The Paul McKenna band - it generates the error
http://www.arranfolkfestival.com/ticket ... f_RI100605

I then did a bulk order and it actually does print a PDF but it contains many errors
http://www.arranfolkfestival.com/ticket ... f_RI100529

I admit that I am in way over my head with this and realise that I may be asking too much to request help with this, especially since this is my first post! But I thought I would try anyway. I've spent a few hours looking at this already, but am getting nowhere. A committee member is coming to my house on Tuesday night to see if I've made any progress -- he has access to the orders database etc.

Thanks in advance.

Re: PHP newbie - need help with ecommerce

Posted: Sat Jan 23, 2010 8:12 pm
by califdon
It's not that we're reluctant to help a first-poster, quite the contrary. But you'll be very lucky if you find someone who has the time to debug a complete ecommerce system for you. I trust that you understand that the error message is telling you that the PHP variable $eventImage hasn't been defined, and has no value, so it can't process your code. What you have to do is determine where that value should be coming from and fix it. Perhaps something has been misspelled (is that really a capital "I"?) or maybe a line has been omitted earlier in the script, or maybe the value was supposed to come from the $_POST value from a form -- something like that. Even with ALL the code available, it could take hours to locate, in the worst case.

Re: PHP newbie - need help with ecommerce

Posted: Sun Jan 24, 2010 4:54 am
by cams
I understand. I kind of thought that anyway. Maybe it's time to start reading the big thick PHP and MySQL book that's on my bookshelf. Never did get around to starting it. But this ecommerce thing has to work and it's quite time critical, so I guess we'll need to find someone with the skills.

I can just remove the whole $eventImage line and it then prints a PDF but it's still riddled with errors.

Would this error message occur if the variable were defined but it just couldn't find the image in question? You see it does print an image for some of the orders. I don't know enough to figure out where that image is coming from. But if it tried to get an image that wasn't there, would that error message be a likely symptom of that?

Re: PHP newbie - need help with ecommerce

Posted: Sun Jan 24, 2010 12:20 pm
by califdon
No, "undefined" means that the variable is undefined in the code. It is the first time the code has encountered a reference to it. It's a fatal error and PHP cannot proceed any further in the script. To find out where it should be coming from requires someone to examine the entire application and determine what kind of information that variable is intended to hold, then figuring out the logical source for that information--is it supplied via a form by the user? is it determined at the server, based on database retrieval? etc.

It is being used as the first argument to the function addJpegFromFile(), so I'd guess it's a filename, and it might be something that was specified by the user in a form that is in either the same or a different PHP script. If that's the case, this script must have a series of lines near the top that assign the POST data to variables, something like $eventImage = $_POST['eventImage'];. If such a line doesn't exist, or it isn't spelled the same, or if there is no <input> or <select> form element of the form with "name='eventImage'", then the variable would remain undefined. This is the kind of analysis that must be done.