Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Well there are quite a few: #1 $time = strtotime($row['date']); print date('r', $time); #2 list($year, $month, $day) = explode('-', $row['date']); print date('r', mktime(0, 0, 0, $month, $day, $year));
  2. $result refers to a result from a query execution (like: mysql_query()).
  3. No, there are just few words in japanese... the rest are in english. If you use differing languages within one document then you need according to the W3C (http://www.w3.org/TR/html401/struct/dirlang.html) specification add a lang attribute specifying the language of the contents of the element and if necessary even provide a dir attribute. More specific: http://www.w3.org/TR/html401/struct/dirlang.html#h-8.1.2
  4. via HTTP? Is this possible? But then how will it then store a cookie in his temporary directory so his browser can read it?
  5. You have to look at it this way: If I add a cookie to my cookie jar can you then eat my cookies? (Yes if you know where I live and where I keep the cookie jar) The same goes for what you are trying to do, your cron job does "nothing" (it does something but not the expected behavior as you see it) when it comes across the cookie. The reason for this is because you probably don't understand what a cookie actually is. A cookie holds a piece of information for a given domain on your local hard drive (usually in the temporary internet files). This cookie is created whenever your browser receives a Set-Cookie response header and is removed when it's time-to-live (TTL) expires, all managed by your browser. And because your browser is in no way involved in the cron-job process it will also never store a cookie. And thus by declaring this line of code: setcookie("user", "ADMIN"); did you in theoretical terms make your cron-job (read server) an administrator
  6. phpfreaks.com provides tutorials on these subjects. Head to: http://www.phpfreaks.com and enter pagination into the search bar and you'll find a good tutorial written by Crayon Violent.
  7. have you tried modifying the content type? Of both the html and php to the japanese content type? http://en.wikipedia.org/wiki/Japanese_language_and_computers
  8. use file() instead. (http://be.php.net/manual/en/function.file.php) Check for special characters like [, *, .. However a better choice would be naming the different types you have within the document and assign each one some signature to clearly identify each type. u;resourcez.com n;photoangels r;/a[^a-z0-9]*n[^a-z0-9]*o[^a-z0-9]*n[^a-z0-9]*t[^a-z0-9]*a[^a-z0-9]*l[^a-z0-9]*k[^a-z0-9]*/i Now it allows you to expand it in the future with new types plus it allows you to easily identify each line. switch ($type) { case 'u': //logic break; case 'n': //logic break; case 'r': //logic break; }
  9. The first lines: ob_start() and security_update(): The first one makes sure that during this procedure no output is send (except headers) to the browser, the parameter which is a function callback is called during this process and gets the contents ($buffer) passed from ob_start(). The $buffer (output) is then appended with a javascript escaped string (all the jibberish) and unescaped at the very last of the code (r\=r\+s1\;\}return\ unescape\(r\)\) to turn it back into javascript code. To know what it actually says you'll need a tool like FireBug (for FireFox) and execute: alert(unescape(..jibberish..)) which will turn it into human-readable js code. Probably you'll get some javascript code that defends against viruses or some code that translates into a virus (I can't be sure at this time as I haven't converted it yet). This whole mechanism is triggered on this line: echo @urlencode(@base64_encode('id='.$featured_info['photo_id'].'&width=456&height=251')); as to when their is actual output and thus caught by the output buffering mechanism.
  10. Hi, I am using Zend framework and I have created a script which figures out which files I use inside my application (get_included_files()) and stores them in a separate directory. I then move that directory to my project library directory. And when I then try to run my project it starts throwing exceptions or atleast telling me that it can't find the exception classes? And when I change the include_path to include the full framework (with exception classes) it all works fine? Are exception classes not inside the get_included_files()? Edit: And when I change my paths application/settings.ini to ./application/settings.ini It no longer throws that specific exception? I did use chdir() in my script, can that have anything to do with this? Anyway, here is the code: http://pastebin.com/f379f3c05
  11. http://www.phpfreaks.com/forums/index.php/topic,260897.msg1228269.html#msg1228269
  12. $to1=$_GET['news']; if (empty($to1)) /*do something*/; $from1=$_SESSION['username']; if (!empty($_POST)) { $comment1=$_POST['comment']; if(!$comment1 || strlen($comment1 = trim($comment1)) == 0) { echo "Comment not entered"; } else if(!$comment1 || strlen($comment1 = trim($comment1)) < 10) { echo "Comment too short, must be 10 characters at least"; } else if (!$comment1 || strlen($comment1 = trim($comment1)) > 10) { echo "".$from1.", you have added a comment "; $query="INSERT INTO ".TBL_NEWSCOMMENTS." VALUES (NULL '$to1','$comment1', now(), $from1)"; mysql_query($query); } }
  13. $time = 0; for (..) { $time += strtotime($row['timestamp']); } print date('r', $time);
  14. It does that Genre ..Movie Titles.. Genre2 ..Movie Titels.. Genre3 ..Movie Titles..
  15. <?php $movies = array ( array ( 'Gener'=>'Action', array ( 'Name'=>'Pirates of Carebian', 'Gener'=>'Action', 'Year'=>2003, 'Cast'=>'Johnny Depp' ), array ( 'Name'=>'Matrix', 'Gener'=>'Action', 'Year'=>2001, 'Cast'=>'I don\'t know' ) ), array ( 'Gener'=>'Horror', array( 'Name'=>'The Eye', 'Gener'=>'Horror', 'Year'=>2002, 'Cast'=>'Some creepy people' ), array( 'Name'=>'The Eye', 'Gener'=>'Horror', 'Year'=>2002, 'Cast'=>'Some creepy people' ) ), array ( 'Gener'=>'Romance', array( 'Name'=>'Titanic', 'Gener'=>'Romance', 'Year'=>2003, 'Cast'=>'Some creepy people' ), array( 'Name'=>'Love', 'Gener'=>'Romance', 'Year'=>2008, 'Cast'=>'Wierd things happen' ) ) ); foreach ($movies as $movie) { // 0 => array ( "Genre" => "Action", array ( movie ), array ( movie ) ) $genre = $movie['Gener']; print "<h2>$genre</h2>"; print '<table>'; print '<tr>'; print ' <th>Name</th>'; print ' <th>Gener</th>'; print ' <th>Release Year</th>'; print ' <th>Cast</th>'; print '</tr>'; $sizeof = sizeof($movie) - 1; for ($i = 0; $i < $sizeof; ++$i) { print '<tr>'; $movieName = $movie[$i]['Name']; $movieGenre = $movie[$i]['Gener']; $movieReleaseYear = $movie[$i]['Year']; $movieCast = $movie[$i]['Cast']; print "<td>$movieName</td>"; print "<td>$movieGenre</td>"; print "<td>$movieReleaseYear</td>"; print "<td>$movieCast</td>"; print '</tr>'; } print '</table>'; } However if you are creating data structures like that then you may want to step away from array's and start looking at object oriented programming (OOP) class Actor {} class ActorCollection { protected $_actors; public function addActor(Actor $actor) {..} } class Movie { protected $_name; protected $_genre; protected $_releaseYear; protected $_cast; public function __construct($name, $releaseYear, ActorCollection $cast) { .. } } class MovieGenre { } class MovieCollection { protected $_movies; // array ( Genre => array ( Movies ) ) public function addMovie(Movie $movie) {..} public function findByGenre($genre) {..} } print new MovieCollection(new MovieCollectionDbAdapter('SELECT * FROM movies')); // which would output something like: // Genre // Name Release Year .. // Genre // Name Release Year .. // .. This is a very incomplete version of what you actually need but it gives you a good idea of what it allows you to do.
  16. This second line is never executed.. It's also very unwise to close something you just opened. return ($this->connect); mysql_close("$this->connect");// You are calling Member::DbConnect() with no parameters, that's why: Warning: Missing argument 1 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34 Warning: Missing argument 2 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34 Warning: Missing argument 3 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34 Warning: Missing argument 4 for member::DBconnect(), called in C:\xampp\htdocs\test\db.php on line 75 and defined in C:\xampp\htdocs\test\db.php on line 34 You are mistaken your db username for your db host: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'geedy123' (11001) in C:\xampp\htdocs\test\db.php on line 35 Unknown MySQL server host 'geedy123' (11001)
  17. All of 'em It's a bad habbit tought by newb tutorial writers. Use a combination of set_error_handler() and trigger_error() or grow up and start writing OO flavored with design patterns and use Exception's to handle errors
  18. http://mediumexposure.com/techblog/smart-image-resizing-while-preserving-transparency-php-and-gd-library or http://www.imagemagick.org/script/index.php
  19. <?php echo $_SERVER['REMOTE_ADDR']; ?> Is not the real ip address if the user: - uses a proxy - uses shared internet function getip() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; // shared internet } else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { return $_SERVER['HTTP_X_FORWARDED_FOR']; // behind a proxy } else { return $_SERVER['REMOTE_ADDR']; // directly connected to the internet } } Which one?
  20. This will not work when you upload it to a server: <a href="file:///E|/website/xampp/htdocs/testsite/temp.php">forum</a> <a href="file:///E|/website/xampp/htdocs/testsite/temp.php">screenshots</a> The refreshing is normal. You can overlap this using Ajax technology (JavaScript) Don't use inline styles (i.e. <style></style>) <td width="30" height="25" class="myClass" background="<?php echo $plaatje[14]; ?>"><a title="<?php echo $eigenaar[14]." is eigenaar van dit gebied"; ?>" style="display:block"> </a></td> <td width="30" height="25" class="myClass" background="<?php echo $plaatje[15]; ?>"><a title="<?php echo $eigenaar[15]." is eigenaar van dit gebied"; ?>" style="display:block"> </a></td> Use a loop to do this for you. If you ever tend to enlargen your map you will be otherwise writing it all over again. Use semantics: tables are meant for tabular data, a website is not tabular data. Create convenience functions for both db('open') as for db('close'). If you ever work in a team, your teammates may have a hard time figuring out what the db() function does or which parameters it should take (if insufficient documentation is provided). Remove "or die()" it's a bad habbit. Use a combination of set_error_handler() and trigger_error() instead. $pic = Array(48); Does not create an array with 48 places instead it creates array ( 0 => 48 ) Use something differently then: $_POST['west']. Imagine I submitted this form to your game: <input type="hidden" name="west" value=".."> <input type="hidden" name="north" value=".."> <input type="hidden" name="south" value=".."> <input type="hidden" name="east" value=".."> Where would I end up? That's all.
  21. Your doing double work doing: SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `questions` While it should be: SELECT * FROM questions ORDER BY rand() Please post your db scheme tableName (columnName, ..) ..
  22. function cmp_Windows($a, $b) { return _cmp($a, $b, 'Windows'); } .. function _cmp($a, $b, $itemName) { return $a->{$itemName} - $b->{$itemName}; }
  23. Sure use file_get_contents() or curl to fetch the pages content. Use something like simplexml to go over your content and look for any img or a tags. Modify the paths: images/avatar.gif to: http://domain/images/avatar.gif same for the a element. Save the contents file_put_contents('pagename.html', $simpleXml);
  24. DELETE FROM master_name, WHERE should be: DELETE FROM master_name WHERE
×
×
  • 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.