ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
Memcache: http://be2.php.net/memcache + what rhodesa said
-
[SOLVED] PHP Date Issue for auto payment reminder
ignace replied to jarvis's topic in PHP Coding Help
mktime($row['date']); should be: $joined_date = strtotime($row['date']); http://be.php.net/mktime requires it's parameters to be integers and if they are not they are converted to them abiding by the type conversion rules. print (int) "hello world"; // 0 Thus: mktime($row['date']); equals mktime(0); which equals the current date in seconds. Therefor $joined_date ~ $todays_date. Then you convert to days which is 0 as the difference between today and today is 0 -
File Upload, Database Creation, and Page Creation
ignace replied to Snowdawn's topic in PHP Coding Help
Is not an actual webpage as that would be hard to maintain they rather use .htaccess that converts the address to something like: index.php?section=models&id=1345 Can you give a specific url to the script you are trying to imitate then just the website? -
That's actually entire up to you, plus this should have been posted in application design or something.
-
Not entirely sure that I get it but you select all alerts for a specific user and all alerts that have not been assigned to users, is this correct?
-
Redirect Q - Warning: Cannot modify header information
ignace replied to beaner_06's topic in PHP Coding Help
echo "Success!"; header ("Location: http://www.ryanbuening.com"); Chicken and egg problem You want to display a success text however you also want to redirect the user but you can't as you have already sent information How about: <a href="somewhere">Proceed</a> Or before you output succes: header('Refresh: 0; URL=somewhere'); Increase 0 if it needs to wait longer -
Rhodesa can you explain this to me, as I don't exactly understand what you are doing here?
-
messages --------- id message display_type ENUM('once', ..) NOT NULL DEFAULT once users ----- id username users_messages --------------- users_id messages_id read BOOLEAN NOT NULL DEFAULT FALSE SELECT m.* FROM messages m JOIN users_messages um ON m.id = um.messages_id WHERE um.users_id = % AND um.read = FALSE AND m.display_type = 'once' UPDATE users_messages SET read = TRUE WHERE messages_id = % AND users_id = %
-
[SOLVED] How to remember POST variabe from html
ignace replied to etxnreg's topic in PHP Coding Help
Do realize that this code has parts missing like validation. And if you would use this code as-is you will not be able to display form specific error codes. -
[SOLVED] Session Help - Passing Variables Between Pages
ignace replied to skot's topic in PHP Coding Help
http://www.phpfreaks.com/forums/index.php/topic,261112.msg1230646.html#msg1230646 -
You could list all files at once (and using javascript only display one branch at a time) or display upon request: Display upon request: $expand = $_POST['expand'];//don't forget to validate function create_tree($directory) { global $expand; $files = scandir($directory); print '<ul>'; foreach ($files as $file) { $basename = basename($file); if (is_dir($file)) { print "<li><a href=\"currentfile.php?expand=$file\"><img src=\"images/folder.png\" alt=\"folder\"> $basename</a></li>"; if ($file === $expand) { print '<li>' . create_tree($expand) . '</li>'; } } else { print "<li><a href=\"currentfile.php?expand=$file\"><img src=\"images/file.png\" alt=\"file\"> $basename</a></li>"; } } print '</ul>'; } create_tree(realpath('/path/to/expandable/directory')); This code is only intended to show you how you can faciliate this and is not intended for production use. A better aproach would be using the composite pattern. Edit: preferrably use mjdamato's solution, although I have one remark: why not create constants for the $to_return types? like DTA_RETURN_FILES?
-
image/doc is not the mimetype of a word document it's application/msword
-
[SOLVED] How to remember POST variabe from html
ignace replied to etxnreg's topic in PHP Coding Help
This code isn't entirely correct, it will delete any post values on the last page: $_POST = array_merge($_SESSION['_POST'] /*stored values*/, $_POST /*post values from the last page*/); Should fix this problem. -
No, your code and SQL will still work you only need to adjust the paths. That's not true. If you have a file located in /includes/somefile.php and now I move somefile.php to /somedir. Then how will this code still works? require_once('/includes/somefile.php'); Consider to always use absolute paths using either realpath() or by defining directory constants: defined('__DIR__') or define('__DIR__', dirname(__FILE__)); //__DIR__ exists as of PHP 5.3.0 define('DOCUMENT_ROOT', __DIR__); require_once(DOCUMENT_ROOT . '/includes/somefile.php'); Personally I prefer realpath() as it modifies the directory separator to the underlying operating systems' directory separator.
-
PHP Newbie: Login Security and General Security
ignace replied to metalspawned's topic in PHP Coding Help
Nothing is ever really secure. When it isn't the code, it's the server, .. No one can ever guarantee 100% security, only 99.9% at its best however that 0.1% will come back to haunt you They have told me that your application's code is only as good as the company's worst programmer, and it's true. Even if computer's themselfs wrote it, it still wouldn't make it 100% proof. And don't believe everything they say, if we would believe everything they say we would have died a few times over In 2012 we will die again Ofcourse I'm not saying that you should just rely on any code but if you do - test it yourself - use unit testing for example (http://en.wikipedia.org/wiki/Unit_testing). If it passes all your worst case scenario's then you can be sure it will do to (for 99.9%) in the real world to. -
$news "CREATE TABLE `news` ( should be: $news = "CREATE TABLE `news` ( hence the =
-
Even better yet
-
$content[] = $row->title; $content[] .= $row->content.'<br />'; is incorrect, what you actually should do is this (assuming you know what I mean with $i): $content[$i] = $row->title; $content[$i] .= $row->content.'<br />';
-
OO is much more then just fancy classes, it's meant to improve re-use. Their are many techniques that you can apply that will improve the re-use of your code, one of these techniques is loose coupling. When writing classes you should make sure your class follows the Single Responsibility Principle (SRP, http://en.wikipedia.org/wiki/Single_responsibility_principle) and always remember to refactor your code when necessary (http://en.wikipedia.org/wiki/Code_refactoring) also don't repeat yourself (DRY, http://en.wikipedia.org/wiki/Don't_repeat_yourself) and keep it simple (KISS, http://en.wikipedia.org/wiki/KISS_principle) No it is not. Same applies for formatting directly in html (unless the classes's single responsibility is the formatting of data to html). Always make sure their is a clear separation of concerns (http://en.wikipedia.org/wiki/Separation_of_concerns) between your classes. When you are writing code always remember to stick to some identifier naming convention. It makes your code more readable and maintainable. Now to come back to your code and your actual question: when you write a class you need to think about the added value that this class makes to your application. For example you have created a Database class, however it has no added value. All it does is proxy MySQLi, actually your class is making it even worse as it limits the possible result set MySQLi provides. If I perform Database::select_query('..'); all I'll ever get is a numerical array? And what's worse of all, all my future tables needs to have a title and a content column. And if it has no added value then don't write it and use what's available.
-
Use ExtJS as it more easily faciliates widgets: var tab1 = new Ext.Panel({ title: "Tab 1", autoLoad: "ajax.get-tab-contents.php?tab=1" }); var tab2 = new Ext.Panel({ title: "Tab 2", autoLoad: "ajax.get-tab-contents.php?tab=2" }); var tabPanel = new Ext.TabPanel({ renderTo: Ext.getBody(), activeTab: 0, deferredRender: false, items: [tab1, tab2] });
-
Read this: http://www.tuxradar.com/practicalphp/18/1/10
-
http://be.php.net/chmod
-
Ok so you have one category table? Do you have a field which identifies the parent? Something like: category ---------------- id parent_id 1 0 // not a child 2 1 // child of 1 3 1 // child of 1 4 2 // child of 2 5 3 // child of 3 $currentCat = (int) $_GET['category']; while (list($id, $parent_id, ..) = mysql_fetch_array($result, MYSQL_NUM)) { if ($id === $currentCat) { $query = "SELECT * FROM categories WHERE parent_id = '$id'"; $result = mysql_query($query, $db); while (list(.. } If you are in for some complexity then take a look at the composite pattern as this will do here just nicely
-
We get to the bottom of it