So, I'm writing this PHP script, and I've got an array named $filesArr full of a random list of files.
I can not for the life of me make $listOfFilesInOrder (or whatever) have four entries from $filesArr, then logo.jpg, then four more from $filesArr, then logo.jpg and so on, until the end of $filesArr, then there needs to be one last logo.jpg at the end.
The final goal is to get it into an XML file (with stuff before and after that's not dynamic) that looks like:
// which will be logo.jpg
... and so on, with, of course, logo.jpg being every fourth one, and the last one when the list runs out.
I've tried this three different not-f*cking-working ways and I'm just frustrated and tired. Should I just scrap this logical stuff and put it all in a big recursive foreach() loop or something? I'm worried about optimization, 'cause this script gets called first thing when the site gets hit.
Hell, if I can just get someone to explain the damn logic, that would help. I'm the world's most lame coder, having a lame problem, with a lame language. It's a lame shame.
If it helps, the project is a slideshow thing for this client.
I've got a Flash slideshow-type application, built with half-stolen-functions-half-written-actionscript. I can't dynamically get a list of files to pick from, 'cause I just don't think AS does that. So, I figure to get the list from an external XML file.
But, then, I was thinking, why not make that XML file dynamically generated so that I don't have to edit this guy's site every time he wants to add pictures. He can just drop a picture in the directory, and the next time someone hits the site, it'll be added to the rotation. But, evidentally, you can't do that with AS either, (or I can't figure out how) so I'm putting this PHP script together (for the app to call) to get a list of all the files, randomize it, put them into order (above), then write the whole thing to an XML file for the Flash app to use.
The workhorse part of the flash app is done. I'm gonna loadMovie it into the site framework part, which won't take a second to put together. The hold up is my inability to make PHP do a simple f*cking task in a logical way. If I can get this script WORKING, then I can spend only a few more hours, put this thing up, and pick up my check quick-as-a-bunny.
Obviously the hole in this solution to the problem is the fact that the script runs every time someone hits the page. I'm open to suggestions on how to solve that little conundrum. Should I just include it as a tool and have this guy run it whenever he updates? That would solve the optimization problem, but then it wouldn't be different for each user. Maybe set up a cron job to do the change once a day or something.
Okay, I'm having a bit of a problem here... I'm trying to create an RSS feed from my MySQL database. Unfortunately though, I can't seem to write to a file. PHP isn't running in safe mode, and the enclosing folder permissions don't seem to make a difference. The file gets created, but no writing occurs, and if the 'is_writeable' statement is taken out, the script runs until it times out and gives an error 500. Anyone have any clues?
error_reporting(1);
include("sqlstuff.inc");
$filepointer = fopen("/kunden/homepages/28/d58558265/htdocs/rss/news.rss", "w+") or die ("can't open file");
Without much ado, I present the script.
It handles http and https URL's and should work across platforms and configurations (like using htaccess for clean url's etc.).
To understand more about the issues involved read - Understanding $_SERVER[’PHP_SELF’], $PHP_SELF, $_SERVER[’REQUEST_URI’] and $_SERVER[’SCRIPT_NAME’] in PHP and when to use what
$_SERVER['FULL_URL'] = 'http';
$script_name = '';
if(isset($_SERVER['REQUEST_URI'])) {
[...]
A new version of the WordPress Translator plugin is now available. Please refer to the original documentation for details including installation instructions.
What's New:
Option to generate slimmer list of icons (maximum 5 icons in a row). Now you can use <?php create_translator_bar(true); ?> to create a slimmer version as can be seen in this site.
The default [...]
my exams finished today and i intend to learn PHP for my websites. i've been dying to for such a long time but i have a question. i really don't get this MySQL business- installing it on what? my computer? i have a Mac (PowerBook G4) .. so is it compatible?
it's possible to do PHP in DreamWeaver right? also, if anyone wants to point me in the direction of any easy PHP tutorials... feel free XD
You'll have to excuse my relative noobishness. I'm not great at PHP, but unfortunately I have a job to do.
Has anyone used PHP do do something with PayPal's Instant Payment Notification? I have to run a script that sends different messages to the buyer based on what product they buy. I have a script (mostly copied from PayPalDev, but I'd say I pretty much know what it's doing) that gets the variables from $_POST with fsockopen(). The script already redefines these array variables (i.e., what you would do if register_globals were off), and they seem like they're all there since it sends me mail when $payer_email is used with mail(). The problem I have is that $item_number prints blank every time.
// check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment
// if 'VERIFIED', send email
if ($item_number == 'RCP1101') {mail($payer_email, $subject, "You ordered the book", "From: $from");}
else if ($item_number == 'RCP1102') {mail($payer_email, $subject, $msg_02, "From: $from");}
else if ($item_number == 'RCP1103') {mail($payer_email, $subject, $msg_03, "From: $from");}
else if ($item_number == 'RCP1104') {mail($payer_email, $subject, $msg_04, "From: $from");}
You'll have to excuse my relative noobishness. I'm not great at PHP, but unfortunately I have a job to do.
Has anyone used PHP do do something with PayPal's Instant Payment Notification? I have to run a script that sends different messages to the buyer based on what product they buy. I have a script (mostly copied from PayPalDev, but I'd say I pretty much know what it's doing) that gets the variables from $_POST with fsockopen(). The script already redefines these array variables (i.e., what you would do if register_globals were off), and they seem like they're all there since it sends me mail when $payer_email is used with mail(). The problem I have is that $item_number prints blank every time.
// check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment
// if 'VERIFIED', send email
if ($item_number == 'RCP1101') {mail($payer_email, $subject, "You ordered the book", "From: $from");}
else if ($item_number == 'RCP1102') {mail($payer_email, $subject, $msg_02, "From: $from");}
else if ($item_number == 'RCP1103') {mail($payer_email, $subject, $msg_03, "From: $from");}
else if ($item_number == 'RCP1104') {mail($payer_email, $subject, $msg_04, "From: $from");}
You'll have to excuse my relative noobishness. I'm not great at PHP, but unfortunately I have a job to do.
Has anyone used PHP do do something with PayPal's Instant Payment Notification? I have to run a script that sends different messages to the buyer based on what product they buy. I have a script (mostly copied from PayPalDev, but I'd say I pretty much know what it's doing) that gets the variables from $_POST with fsockopen(). The script already redefines these array variables (i.e., what you would do if register_globals were off), and they seem like they're all there since it sends me mail when $payer_email is used with mail(). The problem I have is that $item_number prints blank every time.
// check the payment_status is Completed // check that txn_id has not been previously processed // check that receiver_email is your Primary PayPal email // check that payment_amount/payment_currency are correct // process payment
// if 'VERIFIED', send email
if ($item_number == 'RCP1101') {mail($payer_email, $subject, "You ordered the book", "From: $from");}
else if ($item_number == 'RCP1102') {mail($payer_email, $subject, $msg_02, "From: $from");}
else if ($item_number == 'RCP1103') {mail($payer_email, $subject, $msg_03, "From: $from");}
else if ($item_number == 'RCP1104') {mail($payer_email, $subject, $msg_04, "From: $from");}
I was unable to send trackbacks and pingbacks after I tested with WordPress 1.5.1.2. I found the solution yesterday.
I had too many XMLRPC Ping servers on my list and the php process was timing out while still pinging to them and before it could execute the trackback/pingbacks associated with the post.
The obvious solution [...]
I have been asked to build a sales/order/customer/employee management system for my company. I am having a problem deciding how to set up the "sales/order" tables. The company sells domain registration, hosting, web design and on hold messaging. I cant store all the orders in one table called orders simply because all the different products have different information that needs to be stored but I am just not sure that 3 separate tables is the way to go.
The website table would contain: order# | designer | start_date | completion_date | salesman | customer# | sales_date
The hosting table would contain: order# | domain_name | start_date | location | salesman | customer# | sales_date
The domain table would contain: order# | domain_name | start_date | salesman | customer# | sales_date
Should I have one table called orders that contains the common columns like salesman, customer# and sales_date and then use the order# to get the information from appropriate table? The company will probably add more products in the future.
I have been asked to build a sales/order/customer/employee management system for my company. I am having a problem deciding how to set up the "sales/order" tables. The company sells domain registration, hosting, web design and on hold messaging. I cant store all the orders in one table called orders simply because all the different products have different information that needs to be stored but I am just not sure that 3 separate tables is the way to go.
The website table would contain: order# | designer | start_date | completion_date | salesman | customer# | sales_date
The hosting table would contain: order# | domain_name | start_date | location | salesman | customer# | sales_date
The domain table would contain: order# | domain_name | start_date | salesman | customer# | sales_date
Should I have one table called orders that contains the common columns like salesman, customer# and sales_date and then use the order# to get the information from appropriate table? The company will probably add more products in the future.
I've been wrestling with this query all afternoon. I've read the MySQL docs and got some help from the PHP LJ group, but now I'm totally stuck.
I have this query:
SELECT nuke_project_milestones.start_date,
nuke_project_milestones.length_num,
nuke_project_milestones.length_type,
date_add(nuke_project_milestones.start_date, INTERVAL nuke_project_milestones.length_num nuke_project_milestones.length_type)
AS estfinish FROM nuke_project_milestones
To my mostly untrained eyes, it looks okay, but when I run it, I get this error:
#1064 - 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 'nuke_project_milestones.length_type) AS estfinish FROM nuke_pro
Poking and prodding around leads me to believe it has something to do with the length_type variable, which is a 5-character varchar, which I set through my PHP script to be DAY, MONTH, or YEAR.
So, in short, what am I doing wrong? (With this query, anyway.)
Lil' help? I am trying to get something done for the client in the next half hour... but I am a Sessions newbie.
FIXED - SYNTAX ERROR IN THE FORM/POST DATA
I've set a session variable at log-in: $office_id = $_SESSION["office_id"]; (works fine).
However, there is a special instance when the manager-user needs to change the value of $_SESSION["office_id"] during the session. How do you change a session variable's value?
I am at this minute searching PHP.net, but hopefully some kind programmer can help me out. As always, thanks to anyone who lends a hand!
I've tried looking in PHP and MySQL docs for this, and just regular google searches, and I'm coming up nil. (Despite being fairly sure I found this the other day.)
I have a date (YYYY-MM-DD), a length, and a length type (day, month, or year). I want to add the length to the date to get a new date. How do I do this?
*staples a note that says "Bookmark" to her forehead
Hello, I’m a second year Computer Science student at Cal Poly, SLO. With no open source or real world experience however I'm really eager to get involved in the open source community and start help developing software. Does any one have any suggestions for a newb. I would like to work on development of web applications preferably using PHP, MySQL, XML and using Asynchronous JavaScript and XML (Ajax). However I am a beginner in all of these languages.
- What would be some good starting points for me? (Communities, progjects, work) - Being that I'm a beginner how do I go about finding simple tasks/projects to start out with? - Live Journal looks interesting to me but I have my heart set on learning PHP not perl. Is this dumb? Should I not be focused on the language but rather the project?
Thanks in advance for any advice you have for a newb.
Awhile back, I started a SourceForge project with the goal of using it as a tool to better learn PHP & Smarty. I'm a CS graduate with experience working in C/C++, Perl, and especially ColdFusion (due to work), and I've decided that it's a good idea to learn PHP and Smarty, and what better way to do that than with an actual project that might be of some use to someone?
The problem is that, as a fairly new developer, it's freakin' hard to get a project like this off the ground the right way. I don't know the best practices for laying out the app's directories, where I should put my smarty files, that sort of thing. As a software engineer I understand and will be doing requirements analysis, use cases, the database schema(s), etc, and I understand PHP well, having hacked up some wikis and that sort of thing. It's just difficult to get a project like this off the ground. So, what I'm hoping is that there's one (or more, even) people out there who might be interested in working on a PHP project they can show off to others, and are willing to provide a little guidance. The project's website is http://sourceforge.net/projects/phpbling - you'll not ethat I started it over a year ago; unfortunately, right after that things got terribly busy :) but now with a little more time, I want to get back at it.
The CVS has an initial stab at a directory layout and some config/environment stuff, taken from a suggested best practices on the smarty website, but I already have some questions on that, too.
Let me know if you're interested. Email to my username @ livejournal.com is fine. if nobody's into it, then I'll probably just go ahead and fuddle through my own way, but it sure would be nice to get some knowledge in from the beginning so that we/I don't have to redo it later!
Awhile back, I started a SourceForge project with the goal of using it as a tool to better learn PHP & Smarty. I'm a CS graduate with experience working in C/C++, Perl, and especially ColdFusion (due to work), and I've decided that it's a good idea to learn PHP and Smarty, and what better way to do that than with an actual project that might be of some use to someone?
The problem is that, as a fairly new developer, it's freakin' hard to get a project like this off the ground the right way. I don't know the best practices for laying out the app's directories, where I should put my smarty files, that sort of thing. As a software engineer I understand and will be doing requirements analysis, use cases, the database schema(s), etc, and I understand PHP well, having hacked up some wikis and that sort of thing. It's just difficult to get a project like this off the ground. So, what I'm hoping is that there's one (or more, even) people out there who might be interested in working on a PHP project they can show off to others, and are willing to provide a little guidance. The project's website is http://sourceforge.net/projects/phpbling - you'll not ethat I started it over a year ago; unfortunately, right after that things got terribly busy :) but now with a little more time, I want to get back at it.
The CVS has an initial stab at a directory layout and some config/environment stuff, taken from a suggested best practices on the smarty website, but I already have some questions on that, too.
Let me know if you're interested. Email to my username @ livejournal.com is fine. if nobody's into it, then I'll probably just go ahead and fuddle through my own way, but it sure would be nice to get some knowledge in from the beginning so that we/I don't have to redo it later!
Our company's website was recently rebuilt from a collection of many HTML pages assembled over several years to a new mysql-based site. We used to have a large collection of numbered files in a directory called specs, so the url was site.com/specs/6413.htm, for instance. Now it needs to be site.com/display_page.php?p=200&s=6413.
Is there a way I'm unaware of to have it direct misdirected viewers to the correct page? I have access to the 404 page, but I'm unable to rename it from it's default .html and create a dynamic page. Any ideas?