Jump to content

LazyJones

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by LazyJones

  1. CURDATE() has never been a PHP function but can be found from mysql
  2. 1. http://fi2.php.net/manual/en/function.strpos.php strpos($line, "//") will return 0 if line starts with // (some other integer if line contains it) and NULL if it doesn't 2. http://fi.php.net/split with split(",",$line) will return an array of strings (separated by , in array) EDIT: explode will work better for #2 http://fi.php.net/manual/en/function.explode.php thanks, Orio
  3. more of a CSS issue /* for y-axis */ background-repeat: repeat-y /* for x-axis */ background-repeat: repeat-x /* for both */ background-repeat: repeat
  4. You can parse XML data with PHP: 1. If you are using PHP5, I recommend [url=http://www.php.net/simplexml]http://www.php.net/simplexml[/url] 2. If older, check [url=http://www.php.net/xml]http://www.php.net/xml[/url] functions. It's a bit trickier but works.
  5. You can't execute PHP code that way (if that's what you are after). For pulling something out of a string (maybe the url, in this case?), there's lots of useful functions for example preg_match() and strstr() Good question is, why would you have something like that in a variable...
  6. it return "just the integer" because this line [code]$value = $intnum." ".$key;[/code] gives just rounded up value (array_search() returns FALSE, so $key is empty) You can check if array_seach() returns FALSE and return if it does ( return the original value, or what ever you want)
  7. IP address can be fetched from predefined variable $_SERVER['REMOTE_ADDR'] more on subject: [url=http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server]http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server[/url]
  8. The problem is not in the pattern, it's somewhere else (SQL syntax maybe......)
  9. you'd want to fetch the user level from database and compare it if($user_level == 1) header("location:normal_user.php"); if($user_level == 2) header("location:admin.php"); ... or something of that sort. I'll leave the query of the user level as a homework... BTW. session_register('user_level') = 1 makes on sense. session_register() is a function which returns TRUE if the registering is succesfull... and you'll be better off using plain $_SESSION array values (like $_SESSION["user_level"] )
  10. Not sure what you are trying to achieve, but I'll try... Forget rounding [code] if($answer > 10 && $answer < 21) { echo "Answer is between 10 and 20"; } [/code]
  11. Or (to save some resources) have a validation field in the table (simple boolean value. 0 for not validated, 1 for validated). Then you could list all not validated adds and update the validation values for those you want.
  12. would ; in end of the line do the trick?
  13. From [url=http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html]http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html[/url] " To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this: mysql> ALTER TABLE tbl AUTO_INCREMENT = 100; "
  14. I'm no expert in sql, so I would do it in separate queries. That is, first get the hotel, then query the specials and loop trought them.
  15. With a quick look, you are fetching an array from the result twice. First after the query and then in the while loop. Another question is, why would you need to loop anything; you are clearly fetching only one result  ;)
  16. [!--quoteo(post=347161:date=Feb 18 2006, 02:18 PM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Feb 18 2006, 02:18 PM) [snapback]347161[/snapback][/div][div class=\'quotemain\'][!--quotec--] Anyone else find it a pain sometimes when programming and the differences between English English and American English? Not that its really much of a pain but I am used to spelling it COLOUR and not COLOR. But when programming, be it HTML, VB.NET or whatever I'm always having to remember to use COLOR ;) Just useless banter I suppose :) [/quote] I'm finnish, so it doesn't bother :) But did you now that there's a programming language called [a href=\"http://en.wikipedia.org/wiki/English_programming_language\" target=\"_blank\"]English[/a] ;)
  17. One solution could be read file into an array with file() function, then each page fetch the lines you need from that array.
  18. First, helping is always easier if you provide us with the actual error message, not just say that "there's an error" Second, your code looks pretty confusing. You are talking about updating, but it's nowhere to be seen. Your 'new php file' has some form elements with no clue etc... Try this, and maybe things will open up a bit foreach ($_POST as $key=>$value) { echo "$key - $value <br>"; }
  19. [!--quoteo(post=335816:date=Jan 12 2006, 05:16 AM:name=cachobong)--][div class=\'quotetop\']QUOTE(cachobong @ Jan 12 2006, 05:16 AM) 335816[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi guys! can u help me with my SQL? here's what i want to happen... TMP_TABLE.remarks = TMP_TABLE.state plus TMP_TABLE.zip that is for all fields..how do i do it with only 1 SQL statement? With this lack of information, helping would be just like shooting in the dark... What exactly are you trying to do? Insert new value, update, search? What are those values? Are you trying to add two intergers? or maybe doubles? Or trying to concat two strings? Try to place yourself in our position and think if you could manage to help with that kind of question.
  20. [!--quoteo(post=335531:date=Jan 11 2006, 10:35 AM:name=JohneeMac)--][div class=\'quotetop\']QUOTE(JohneeMac @ Jan 11 2006, 10:35 AM) 335531[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi there, i am trying to display some news with the most recent date at the top heres my SQL: $sql = mysql_query("SELECT *, date_format(article_date, '%D %M, %Y') as article_date FROM news_system ORDER BY article_date ASC LIMIT 5"); It seems to mess up and have a random order of things. Thx. It most certainly will. The mysql engine sees the dates like this (12.10.2005 -> 12102005, 24.12.1856 -> 24121856) so 24121856 is definetly bigger then 12102005. The date format should be arranged first by year, then by month and then date. Or maybe use TIMESTAMP() instead.
  21. Valuable stuff, Fenway, thank you for that. 26 database calls isn't the optimized way. But at least I had the LIMIT
  22. You could build a function that would check if database has match for that letter, like this: function inDb($letter) { //search database on first letter, LIMIT is because one is enough $query = "SELECT col_clientName FROM tbl_TEST WHERE clientName LIKE '$letter%' LIMIT 1"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result) > 0) { return true; } else { return false; } } and where you display the links: ... if(inDb($letter)) { echo " <a href='letterTEST.php?page=$letter'>"; echo $letter; echo "</a>"; } else { echo $letter; } ... Haven't tested the code, but maybe you get the basic idea.
  23. the s.nickname is just what you wanted, so don't take it out. What was the error then? (look for my signature for error hunting).
  24. [!--quoteo(post=334406:date=Jan 7 2006, 03:59 PM:name=Hef)--][div class=\'quotetop\']QUOTE(Hef @ Jan 7 2006, 03:59 PM) 334406[/snapback][/div][div class=\'quotemain\'][!--quotec--] Ok, all I want to do is have a date column that gets updated when the record is first created by mysql. Using phpmyadmin i selected "date" for the "type", but that didnt do it. PHPMYADMIN keeps inserting 0000-00-00 into the default setting for the date field. dont know why. Thanks, Hef The value you are inserting must be in the same format as the DATE column. Present time in that format would be given by: echo date("Y-m-d",time());
  25. [!--quoteo(post=333983:date=Jan 6 2006, 08:49 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ Jan 6 2006, 08:49 AM) 333983[/snapback][/div][div class=\'quotemain\'][!--quotec--] be careful, because different SQLs will handle IDs differently, and you could very well skip over an id entirely this way. What do you mean by this? Auto increment works differently? If so, there's no solution to this one. Let's say you do it my way. Add a row, the ID becomes 7, delete it and next will (or will it?) be 8
×
×
  • 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.