Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
You need to give mysql_select_db() the actual name of your database, i.e. mydomain_test1. When you've created the database then you can have as many tables as you would like inside that database. Seeing as you have a curious way of using punctuation and spacing I don't think that will be possible
-
NOW() is a MySQL function and not a PHP function. You must use it inside the query like toplay explained.
-
[SOLVED] ORDER BY Clause.....something is amiss here.
Daniel0 replied to maliary's topic in MySQL Help
There is no point in having an ORDER BY if you limit it to one row. -
I wish I had your design skills. It looks awesome.
-
@dsaba: All URLs does not need at least one dot. E.g. from within my LAN my computer will be accessible by the name daniel-laptop. That means that http://daniel-laptop will be a valid URL from within my LAN seeing as my computer is running an httpd on port 80.
-
Try to change if(filemtime($cache_file) + 1*60 > time()) to if(filemtime($cache_file) - 1*60 > time() || !file_exists($cache_file)) Then delete cache/menu.html and try again.
-
Could you post the code you have?
-
Just spotted an error in the class. Updated: <?php class Cache { static protected $cache_dir; protected $contents; protected $path; public function __construct($filename) { $this->path = self::$cache_dir . $filename; if(!file_exists($filename)) { throw new Exception("Cache file '{$filename}' could not be found"); return false; } $this->contents = file_get_contents($this->path); } public function isOlderThan($seconds) { return filemtime($this->path) + $seconds < time(); } public function update($new_content) { $this->contents = $new_content; file_put_contents($this->path, $this->contents); } public function getContents() { return $this->contents; } public function __toString() { return $this->getContents(); } static public function setCacheDir($dir) { self::$$cache_dir = $dir; } } ?> Note: I have not tested this version or any other code I have posted in this topic.
-
Change it to: mysql_query ('INSERT INTO ' . $table . ' VALUES ( {$_REQUEST["Name"]}, {$_REQUEST["Info"]} );'); And then read this: http://php.net/string#language.types.string.parsing.complex
-
I feel generous so I decided to make the class: <?php class Cache { static protected $cache_dir; protected $contents; protected $path; public function __construct($filename) { $this->path = self::$cache_dir . $filename; if(!file_exists($filename)) { throw new Exception("Cache file '{$filename}' could not be found"); return false; } $this->contents = file_get_contents($this->path); } public function isOlderThan($seconds) { return filemtime($this->path) + 30*60 < time(); } public function update($new_content) { $this->contents = $new_content; file_put_contents($this->path, $this->contents); } public function getContents() { return $this->contents; } public function __toString() { return $this->getContents(); } static public function setCacheDir($dir) { self::$$cache_dir = $dir; } } // In another file: require_once 'library/Cache.php'; Cache::setCacheDir('/home/somebody/cache/'); // ... $cache = new Cache('menu.html'); if($cache->isOlderThan(30 * 60)) { // generate content and store in $menu_html $cache->update($menu_html); } else { $menu_html = $cache->getContents(); } ?>
-
You could do something like this: <?php $cache_file = 'cache/menu.html'; if(filemtime($cache_file) + 30*60 > time()) { // generate the content here and store it in $menu_html; file_put_contents($cache_file, $menu_html); } else { $menu_html = file_get_contents($cache_html); } ?> You might want to expand it and make it into a class so you can do this: <?php $cache = new Cache('menu.html'); if($cache->isOlderThan(30 * 60)) { // generate content and store in $menu_html $cache->update($menu_html); } else { $menu_html = $cache->getContents(); } ?>
-
In that case the query probably failed. Try running the query manually using e.g. the MySQL command line or GUI tools like phpMyAdmin and see what the result is.
-
1) You cannot know if you want to change something later. 2) The amount of saved space is negligible. 3) It takes longer to other people to read. I don't think it's worth nesting ternary operators.
-
You can do something as basic as this: <?php $file = '/home/somebody/the_file.txt'; if(!isset($_POST['content'])) { $content = file_get_contents($file); echo <<<EOF <h1>Edit file '{$file}'</h1> <form action='{$_SERVER['PHP_SELF']}' method='post'> <label for='content'>Content:</label><br /> <textarea name='content' id='content'>{$content}</textarea><br /> <input type='submit' value='submit' /> </form> EOF; } else { if(file_put_contents($file, $_POST['content'])) { echo 'The file was updated'; } else { echo 'The file could not be updated'; } } ?>
-
I'm not quite sure what you're trying to accomplish. Is it template files you wish to cache so they don't have to be parsed at every request?
-
Try to var_dump($wynik); and see what it outputs.
-
$_POST['dropdown'] or $_GET['dropdown'] depending on how you submit the form.
-
Instructions on writing some code written in the imperative mood strongly suggests that it is a task somebody else has assigned to you. Seeing as this is rather trivial it's most likely homework and this is not a "do my homework for me" website.
-
How to create new pages automatically from a form with PHP ??????
Daniel0 replied to toxinhead's topic in PHP Coding Help
Not really, the file must already be on the server. To upload a file do this: http://www.php.net/manual/en/features.file-upload.php -
There are various ways you could do that. You could do a simple SELECT * FROM table WHERE field LIKE '%Simon%'; or you could take use of MySQL's full-text searching. Alternatively, you could use more advanced searching algorithms such as Zend Framework's implementation of Lucene: Zend_Search_Lucene. I suppose that you by searching mean "check if it contains".
-
Ah, didn't realize it was that. I haven't really used any pear libraries, but it's the same naming convention in Zend Framework which is the one I find best for PHP.
-
Check out this: http://php.net/mcrypt http://php.net/gnupg
-
What kind of encryption do you want? PDF has built in support for encryption. Or do you want to encrypt it with e.g. PGP?
-
PHP Answer: No, but you can do it when they are uploaded.