Jump to content

rawb

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by rawb

  1. Thanks much for your reply! I had absolutely no idea that you had to do anything other than put the encoding in a meta tag, but this was the problem! Works like a charm now.
  2. Sorry for the double post.. I was trying to edit the previous message and accidentally hit 'quote' instead and now I can't find the delete option for this post. Any help with the above question is appreciated!
  3. I posted a similar thread in the MySQL help forums about character encoding and inconsistencies when inserting into a database, but these are definitely two distinct questions and I think this one belongs here. I've been told that UTF-8 character encoding supports french characters (and that it is generally the most universal encoding that there is). If that's the case, why don't french characters display correctly with it? See both files here for an example. They are identical except for their character encoding: http://rawbwk.com/french/ Also note the error when trying to validate: http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Frawbwk.com%2Ffrench%2Futf.html The identical code with an 'ISO-8859-1' encoding validates with no errors. What's the deal?!
  4. Ok I've got kind of a weird character encoding problem that I'm going to try to describe as best I can . Basically, I'm having a lot of trouble rendering French characters and there seems to be a general consensus (on google) that utf-8 is the way to go for French. The MySQL database is set up to use the 'utf8_general_ci' collation, and my HTML also uses utf-8 character encoding like so: <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> The Problem: When using the utf-8 character encoding on my html pages, everything appears to work perfectly. However, when I go to PHPMyAdmin and check the database, it inserts weird characters ('é' instead of 'é', for example). When using the 'ISO-8859-1' charset on my HTML pages, everything inserts and retrieves correctly (this is what I'm currently doing). The thing is, I would really like to use the utf-8 charset in my HTML to keep things consistent between my database and my HTML. If this charset is supposed to be able to support French, then why is it doing this? Thanks in advance!
  5. Check out getimagesize(). http://www.php.net/manual/en/function.getimagesize.php
  6. <?php function showMonitor($monitor) { echo <<<HRD <div class="section"> <div class="images"> <img class="logo" src="images/logos/hannsg.png" alt="Hanns-G" /> <img class="monitor" src="images/hannsg/$monitor.jpg" alt="Hanns-G $monitor" /> </div> <div class="description"> <a href="#"></a> <ul> <li><strong>Color:</strong> {$hannsg[$monitor][0]} </li> <li><strong>Size:</strong> {$hannsg[$monitor][1]} </li> <li><strong>Resolution:</strong> {$hannsg[$monitor][2]} </li> <li><strong>Response Time:</strong> {$hannsg[$monitor][3]} </li> <li><strong>Input:</strong> {$hannsg[$monitor][4]} </li> <li><strong>Brightness:</strong> {$hannsg[$monitor][5]} </li> <li><strong>Contrast Ratio:</strong> {$hannsg[$monitor][6]} </li> <li><strong>Viewing Angle:</strong> {$hannsg[$monitor][7]} </li> <li><strong>Pixel Pitch:</strong> {$hannsg[$monitor][8]} </li> </ul> </div> <div class="revieworbuy"> </div> <div class="clear"></div> </div> HRD; } ?> Sorry I forgot to echo the string.. also thrope is right you need to pass that hannsg array to the function or define it within the function...
  7. <?php function showMonitor($monitor) { <<<HRD <div class="section"> <div class="images"> <img class="logo" src="images/logos/hannsg.png" alt="Hanns-G" /> <img class="monitor" src="images/hannsg/$monitor.jpg" alt="Hanns-G $monitor" /> </div> <div class="description"> <a href="#">[/url] <ul> <li><strong>Color:</strong> $hannsg['$monitor'][0]</li> <li><strong>Size:</strong> $hannsg['$monitor'][1]</li> <li><strong>Resolution:</strong> $hannsg['$monitor'][2]</li> <li><strong>Response Time:</strong> $hannsg['$monitor'][3]</li> <li><strong>Input:</strong> $hannsg['$monitor'][4]</li> <li><strong>Brightness:</strong> $hannsg['$monitor'][5]</li> <li><strong>Contrast Ratio:</strong> $hannsg['$monitor'][6]</li> <li><strong>Viewing Angle:</strong> $hannsg['$monitor'][7]</li> <li><strong>Pixel Pitch:</strong> $hannsg['$monitor'][8]</li> </ul> </div> <div class="revieworbuy"> </div> <div class="clear"></div> </div> HRD; } ?> Use the heredoc syntax to echo raw html.. be sure that the closing HRD; is NOT indented, it must be the first thing on a line by itself. You don't need to use the letters HRD either, it's up to you. But that code above should work.
  8. Most of what I've learned, especially while starting out, has been from tutorials online. Here's a good one: http://www.oxyscripts.com/item-418.html . I remember taking an entire night to work through that code, but I learned a ton and actually had a lot of fun figuring it out. That site's got a lot of good ones, check out good-tutorials.com for a ton more.. there are a million PHP tutorials online just google it. Also, take advantage of the PHP manual it's by far the best reference for a programming language that I've ever seen.
  9. I use htmlentities as well to make sure nobody tried to insert any javascript or html. Also be sure to quote your values in the query (I.E. "INSERT INTO table (productId, something) VALUES ('$quote', '$these')").
  10. I don't think the arrow is used for anything outside of OOP. Unless you're just referencing an object's variable and not a method above I think what you're trying to accomplish is done with just a plain vanilla function <?php function filename() { // your code here } filename(); ?>
  11. Without javascript there is no way (that I know of) to send a request from a client to the server to do anything after a certain amount of time. Ways that I can think of to accomplish your goal: 1) use javascript to time the player on the client side and send an ajax request to update whatever needs to be updated in your database after a specified amount of time 2) use a meta refresh tag (or javascript) to time the player on the client side and refresh the page after a specified amount of time.. when the page reloads check to see if the user had run out of time on the previous page and if so update whatever needs to be updated if the user has run out of time 3) php_dave's recommendation of using a cron job to update all records on the server every so often should work 4) you can use php to check and see the amount of time the user was on the previous page and then check to see if it was too long, but this requires action on the user's part so it isn't really automatic... unless used in conjunction with option #2 I guess hope this helps a little
  12. change this $presultafc=$_POST['resultmfc']; $presultother=$_POST['resultother']; to this $presultafc=mysql_real_escape_string($_POST['resultmfc']); $presultother=mysql_real_escape_string($_POST['resultother']); ANY string input that you use in a mysql query should be escaped with this function (this function also takes a second argument, the database resource variable, and ideally that would be included as well). If the user input is not intended to be a string (an integer, for example), be sure to cast it (i.e. $var = (int)$var) to ensure that it is the correct datatype. Also be sure to continue to use those single quotes around your values to prevent certain types of injection.
  13. Assuming the code above works to create two new connections, the only thing that I can think of that could be wrong is you're not including the link identifier in the arguments of mysql_query (i.e. mysql_query("SELECT * FROM something", $connection))...the 'rest' of the code (from the creation of the connections to the all the way up to the output) would help...
  14. If you're trying to overwrite the old table with the same name with this new table structure, drop the 'if not exists'. Please note that you'll loose all your records! If you're trying to edit the table structure and keep your records, http://dev.mysql.com/doc/refman/5.0/en/alter-table.html is a better option.
  15. Thanks for your reply. This does seem plausible, but might not be scalable.. what if I need to add many more than 50 items between items? Is there really no better way?
  16. To check if a value is a round number with no decimal places, ctype_digit() should work (http://www.php.net/manual/en/function.ctype-digit.php). Also you can/probably should cast the type to an integer value before doing anything with it just to be sure. $var = (int)$var;
  17. If you're using PHP to display the result check out substr - http://www.php.net/substr echo substr($date, 0, 10); will turn '2008-07-06 16:46:15' to '2008-07-06'
  18. SELECT * FROM tablename WHERE (id='9' OR id='30' OR id='40' OR id='23' OR id='88') Should return what you need.
  19. Additionally, addslashes accepts a string where explode returns an array.
  20. mysql_fetch_array returns one row at a time. Because your query returns several rows, the statement "$results2 = array($query['total']);" initializes an array with only one element whose single value is the total of the first row only. Instead, try $totalInt = 0; while ($row = mysql_fetch_array($results)) { $totalInt += $row['total']; } This should return the sum of all of the 'total' values involved in the query.
  21. If the relationship is 1:1 then I don't see any downside to just including a 'user_lastip' field in the users table. There doesn't seem like any point in making a separate table when each user only needs 1 entry anyways - only do this if you want to record each ip from which a user connects because the relationship is then 1:many.
  22. $connection2 - mysql_connect($hostname, $user[1], $pass[1]); $connection2 = mysql_connect($hostname, $user[1], $pass[1]); might have just been a typo here on the forums but be sure that that '-' is a '=' in your code.
  23. A table holds all users, a table holds each 'cluster' item, and a table holds the associations. I.E. table users: id name 1 john 2 rob 3 matt table foods: id name 1 pizza 2 burgers 3 chicken table users_foods: user food 1 1 1 2 2 3 3 1 3 2 3 3 john likes pizza and burgers rob likes chicken and matt likes all three That's how I would do it, but I've also seen the associations stored in a text field with some type of separator (and this is probably faster because there are less queries/joins involved - I'm pretty sure I've seen this in phpbb's database design). For example 1:2:3 for matt and 1:2 for john above. Can anyone with more mysql expertise advise as to which method would be most logical and why, or present a better solution?
  24. I'm asking more about the structure of the data itself. I want the order to be something that I can change, like to move and item 'up/down' a list. If I want to order rows in a list with 5000 items and I've got an integer field for the row's 'placement', then when I insert a new row and place it at #50, I've got to update 4950 rows to add one to each of their 'placement' fields. With the structure I've laid out above, I've only got to modify 2 rows when I insert any item.. but I've got to either send a different query for each row when I read the list out to get each item's next item, or I've got to use one query and store the whole table in an array and use php to reorder it - which might end up being slow too...
  25. I have a question about building a linked list structure in mysql/php. I have a database laid out like: id name next (references next row's id) start 1 example1 2 1 2 example2 5 0 5 example3 4 0 4 example4 NULL 0 Basically, I want to start with the row that has the value of column 'start' set to 1, and then continue to the row with the id listed in the current row's 'next' until next=NULL. This means a lot of separate queries to grab the information from each row and then query the db again for the information from the next row. The best way that I can think of doing this would be to query the database just once and store the information in some type of array structure, and then re-order it using a php loop. This can potentially require a lot of overhead for PHP... My question is really this: Is there a better way to accomplish the task above (perhaps a magical mysql query) or a better/similar structure that would accomplish the same thing? I can do it with an integer value and place the item in it's appropriate integer place, but that would require an UPDATE query to every item after an inserted item in a list to add one to it's int value and show that it's gone 'down' a spot in the list. To really simplify here: How do you order items in mysql? Any help is appreciated!
×
×
  • 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.