Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. You probably want to start by creating the mysql table. Then you can simply read the php manual on how to do an insert statement and select. http://us2.php.net/manual/en/mysqli.query.php
  2. It might be worthwhile setting up an array with the tablenames prepended in advance so that you could have this type of code instead: "SELECT * FROM `{$tbl['promotions']}` WHERE `amount` = '{$main->getvar['promo']}'"
  3. "SELECT * FROM `{$sql['pre']}promotions` WHERE `amount` = '{$main->getvar['promo']}'"
  4. techker: Where is the image? Is it on the filesystem or a blob in the database? What is the structure of the tblImages table? As good as fenway is, he can't read your mind.
  5. Why don't you read up on the javascript window.open() function? I think you'll notice that you need a string parameter with something like "width=400, height=500" in it.
  6. There's many ways to do it. One very standard approach would be to keep a database table that has a simple structure like: asset userid timestamp When someone attempts to access an asset, you first do a query from the table to see if there is a row that exists for today. Assuming a mysql database table, this is a very simple query that uses mysql's date functions for comparison. Once you determine that they haven't looked at the asset today, you let them see it, and call a routine to insert a row for that asset in the database.
  7. @ disables php's normal error handling mechanisms, so basically if that include_once() was to fail the script would not stop.
  8. Take a look at packages like Munin, Monit, Cacti, Nagios and OpenNMS.
  9. Yeah php debugging can be a challenge. THere actually is debugging support out there, in particular a lot of people successfully use XDebug along with an IDE like the eclipse with PDT or the Zend editor. XDebug is quite useful for a variety of things, so if you can get a development environment setup with the xdebug extenstion enabled you might find it useful. Also, if this is going to be a long term maintenance project for you, it might be helpful to build in your own debugging console. It's fairly easy to do -- you just add a div at the bottom, and create some simple debugging routines that will spit out that data into the debug div. Great for things like spitting out query variables, session variable contents etc. I've turned around more than one floundering project by adding in that type of capability into a complicated system, and allowing myself and the other devs a quick way of seeing what's going on and calling a few simple debug functions. I usually have a config variable that allows me to turn the debugging on and off, so I have it on in the development environment, but it's turned off in production.
  10. Sure, use UPDATE statements to clean up the ones that are garbage. You can use SQL to find the offenders and fix them prior to conversion. Look at the mysql string handling functions. http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_substr Functions like substr and locate should probably be enough to do the job.
  11. Yeah looks like something is wrong with that date, so it can't convert it. You may instead have to convert the values using PHP and its date handling functions, although this will be very poor performance wise, because you can't use mysql's indexes and just get back the rows you want. You're best off if you can clean the data and insure from now on that it's a valid DATE or DATETIME or TIMESTAMP column.
  12. Nulls, might not work, you will have to test, but you can also add in an AND ISNULL for those if they should be included. If there is a date, but the time element is all 00:00:00 that's fine. Again, read my blog entry to understand why.
  13. So the field in question is a mysql TIMESTAMP column? You can construct what you need using the MySQL Read my ancient blog entry on this topic: http://www.gizmola.com/blog/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html so you understand the underlying principles of why this works. Let's say your timestamp column is named 'createdDate' SELECT * from yourTbl WHERE createdDate
  14. So, you can obviously do this, and use some of the functions you listed. As you surmised, you need to have a download script that implements the technique, however, whatever process PHP is running as does need permissions to the directory(s) where you store the files. The key think is that this directory should not be under the "web root" so there is no way for a user to have a direct link to the file. This script could be called with a simple get parameter: download.php?file=filename You can secure this using whatever authentication scheme you like. Often people have a system that implements a login facilitated by php session handling, and when they instantiate the session, that code will immediately check that the user is logged in and if not user header() to redirect them to the login page and die(). Your download script can include the same code, and voila, you have a download script that will return people files they can not get to directly, but only works for them when they are logged into the system.
  15. You got good advice, but just in case you were wondering, PHP allows for this type of syntax: $basename = 'foo'; for ($x = 1; $x $tempname = $basename . $x; $$tempname = $x; } echo "$foo1 \n"; echo "$foo2 \n"; echo "$foo3 \n"; //etc This isn't used much because it makes for some very confusing and convoluted code, but the '$$' syntax does work.
  16. why not just iterate through and dump the pathnames to an array? $startPath = 'documents/'; $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($startPath), RecursiveIteratorIterator::SELF_FIRST); $paths = array(); foreach ($iterator as $dirIt => $fileObj) { $paths[] = $fileObj->getPathname(); } sort($paths);
  17. Javascript is a necessary evil these days for most people. However there are some great libraries and tools now to help. Most people are using jquery, which can do amazing things for you clientside with much of the complexity hidden from you. Since you need to make some Ajax calls to do what I suggested, I think you'll find it a great help purely for that reason alone. The docs seem really simple and clear to me, so hopefully it will be fairly easy for you to get some quick and productive code together. Also there's a plugin for Firefox called firebug you want to get, that will help you understand what is going on with your ajax calls while you are developing and debugging. The main thing to keep in mind is that your PHP scripts run serverside, so anything you want to do clientside has to be done in javascript or some other clientside technology like activex or flash. In this case jquery ajax calls should be capable of facilitating what you want to accomplish.
  18. In the future, you want to look at your error log. It should tell you what the syntax error is.
  19. Probably needs to be CURRENT_TIMESTAMP. Has to be uppercase.
  20. You can do what you're talking about using files and javascript. Simply have a manifest file of some sort in the localhost version. You need a script that returns the latest offline version number. The online version also needs this script. Then it's simply a matter in the online version of a javascript routine that runs, that calls both scripts and compares the version strings. If there is a newer version, you start the process to download the newer files. Probably the best way to handle that is to have the updates in zip files and you then have the client download the zip update, and unzip it into the proper location. Mambo/Joomla has this capability albeit it not in an automated fashion, for installing modules, and you might also want to look at the serendipity blog, which has an update management repository system called SPARTACUS built into it that will download newer files for plugins and update the server. You can look at code for each to see what they've done. With that said, it sounds like all you really want is to mirror these systems, and there are existing tools like rsync and unison that you should take a serious look at, to see if they could handle your issue for you without having to create your own system. File permissions in regards to php are extremely important to understand obviously, because you could easily lock down a system so that php will not have the required permissions needed to write the updated files where they need to go.
  21. Using the browser history is not the way to handle that problem. What you should do, is store their $_POST input into a session variable. In the form you can read that out of the session (if it exists) and repopulate the form using html.
  22. When you include code in your posts do this: [code=php:0] ... your php code here [/code] And it will look the way dezkit's reply to you looked, which is easier for everyone to read.
  23. One of the best ways to reduce the complexity is to break it down into discrete pieces. In your case I would suggest a session class that handles sessions. You can create that and unit test it. Again you can look at the Zend framework and see what they did as well. Two classes that I find very useful are a config class and a registry class. They tend to go together. A config class simply provides you a way of reading configuration items that the application will need, like databases, username/password combinations, directory paths, and anything else that you might otherwise put into a configuration file. The purpose of this class is usually to read in all those variables and make them easily available via an object. Along with a config class, and especially in PHP, a registry class is very useful. The idea of the registry is that it can provide handles you require, like files that you need to open for logging or output, database connections, memcache connections, and other things that are typically resources. The registry can be used as a static class, which gets you around having to have lots of object parameters for things you commonly need. So for example, you can use it to setup a database connection and then get access to that connection inside classes that need a database handle. $db = registry::get('dbConnection'); You probably want a simple database class uses a database connection you've created and set in the registry, and lets you pass SQL and get back a result set data structure, and does error handling in a sane manner. I'd create a user class, which in the MVC paradigm would be a model. The idea of a model is that all the details of the internal data structures and how the data gets read and written to your database should be hidden inside the class. The user class should bring everything together, so that you can __construct a user, getStatus, register, confirm, login, logout, get userName etc.
  24. There's nothing much to this. Right the individual scripts that perform the individual functions you need. There's a command line php client you should be able to use to call the scripts. The scripts can be called on the required schedule via cron (on linux). Cron is very flexible in that it can be set to run hourly, daily, every minute, etc. whatever you need. Truthfully I'm not a big fan of Wamp, however you can simulate the same idea using php.exe and the windows scheduler. A much better solution for development of apps that you need to run under linux, is to use virtualization like sun virtualbox or vmware workstation, install a linux distro, and do your testing in the virtual machine.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.