Jump to content

eugeniu

Members
  • Posts

    65
  • Joined

  • Last visited

    Never

Everything posted by eugeniu

  1. I'd like to create a database with a table that will store "sets" of flash cards with each set having any x number of flash cards, so I'm looking to have a table that will store one set per entry. But now my problem is, how do I store the flash cards for each set? Would it be a good idea to have them all somehow stored with its set's entry, or should I give each flash card its own entry in another table, with a parameter being what set the flash card belongs to? Or am I missing a better solution? For the sets, I need to store the set title, id, author, and some other properties, and for the flash cards I need to store question, answer, position in set (first, second, etc), and what set it belongs to. What would be the best solution?
  2. The code above states that while $breed is set (exists) do (echo) all of this stuff. Nowhere in the code is $breed unset so yeah, it'll go on forever. What are you trying to do with this script?
  3. You'd need to either make a database of users that are online for reference or have a column in your users table that saves the last time a user was on your website. In your code that shows whether another user is online or not, you'd need to specify which user your talking about. $username = "eugeniu"; $username = // code to retrieve entry for "eugeniu" goes here if (time(); - $username['laston'] < 5*60) // 5 minutes till last on { echo "User is online."; } else { echo "User is not online."; } Hope that helped...
  4. What is the code you use to validate that someone is logged in? Non-members can only see part of all of the content, so there must be something.
  5. Sigh, I gave up trying to do this the way I wanted to and just created a mysql table that has the various word endings I need in romaji (Japanese using latin alphabet) and in kana (Japanese), where I can request something using romaji and get it in kana.
  6. I also tried doing the following: mb_convert_encoding($answer, "ISO-8859-1", "UTF-8"); mb_convert_encoding($rightanswer, "ISO-8859-1", "UTF-8"); But that doesn't work either!
  7. I tried doing iconv("UTF-8", "ISO-8859-1//TRANSLIT", $rightanswer);, but that's not doing anything. Is there something else I'm supposed to use for the first two properties?
  8. Sadly, using that one doesn't seem to make a difference.
  9. string(12) "たべます" string(22) "たべます" Guess not. I tried using htmlentities on the input string, then both strings, but I still get the same problem. Answer: たべ + ます string(12) "たべます" string(22) "たべます" htmlentities()... string(12) "たべます" string(22) "たべます" Fail. たべます =/ たべます
  10. Hehe. I never would have thought of that if I were you .
  11. It's listed as utf8_general_ci. And if it means anything, I have this in my header: header("Content-type: text/html; charset=utf-8"); mb_internal_encoding("UTF-8");
  12. I wrote a script that retrieves a word from a database made up of Japanese characters, adds two more Japanese characters to the script, and has the user enter the new word, in Japanese. For the purpose of debugging, I've simplified the script. The script is supposed to take the submitted word and check if it matches the word from the database, and return "Success" or "Fail". However, no matter how many times I enter the correct word, it determines it's incorrect. The code to the script is shown below: <?php session_start(); $title = "Test Quiz"; $autoselect = "quiz.answer"; include ("header.php"); echo "<h1>Test Quiz</h1><div id=\"quiz\">"; $entry = mysql_query("SELECT * FROM verbs LIMIT 1") or die(mysql_error()); $entry = mysql_fetch_array($entry); $masu = "&#12414;&#12377;"; echo "Answer: $entry[ans_kana] + $masu<br />"; if (isset($_POST['form_submit'])) { $answer = $_POST['answer']; $rightanswer = $entry['ans_kana']; $rightanswer .= $masu; if ($answer == $rightanswer) { echo "Sucess.<br />$answer = $rightanswer<br />"; } else { echo "Fail.<br />$answer =/ $rightanswer<br />"; } } ?> <form name="test" action="test.php" method="post"> <input id="answer" type="text" name="answer" size="10" maxlength="60" /> <input type="hidden" name="form_submit" value="submitted" /> <input type="submit" name="submit" value=">>" /> </form> <?php echo "</div>"; include("footer.php"); ?> The above script can be run at http://kanaquest.com/dev/test.php . The right answer is supposed to be たべます, which is a combination of the string from the database, and $masu. But it seems that when a string from the database is combined with a UTF-8 string, nothing I enter matches the formed string. However, when $rightanswer is only a word from the database, or only a UTF-8 string set in the script, I have much better luck with the script matching up my submitted word with the word in the script. What am I doing wrong?
  13. God am I stupid... I just quickly looked for "day" on php.net's Date page and just saw "01 through something..." and used that. Sigh. Thanks a lot for clearing that up.
  14. I don't understand. The format I have it use is correct. I need something like 14:47, Jul 27, 2009, but while the hour and minute is correct, the month, day, and year is stuck on July 7, 2009.
  15. This problem has been driving me crazy for most of this morning. I wrote a table that took the following information from each user of a database and placed them in a database: username, user level, email, last active, and date registered. You can see a table of this here. For each of the entries in the "Last Active" and "Registered" columns, the first line shows the unix timestamp, and the second line should show the time and date based on that. But it's not doing that correctly. The hour and minutes are correct for each one, but the month, day, and year is the exact same for each!! For each one, it says "Jul 07, 2009". I have no idea where Jul 07 even came from! What in the world is going on? This is the code for test.php: <? include("header.php"); function displayUsers(){ global $database; $q = "SELECT username, userlevel, email, timestamp, dateRegistered FROM ".TBL_USERS." ORDER BY userlevel DESC,username"; $result = $database->query($q); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); /* Display table contents */ echo "<table class=\"users\">"; echo "<tr> <th>Username</th> <th>Level</th> <th>Email</th> <th>Last Active</th> <th>Registered</th> </tr>"; for ($i=0; $i<$num_rows; $i++) { $uname = mysql_result($result, $i, "username"); $ulevel = mysql_result($result, $i, "userlevel"); $email = mysql_result($result, $i, "email"); $lasttime = mysql_result($result, $i, "timestamp"); $regtime = mysql_result($result, $i, "dateRegistered"); $lasttime = (int)$lasttime; $regtime = (int)$regtime; echo "<tr> <td>______________</td> <td>$ulevel</td> <td>______________</td> <td>$lasttime<br>".date("H:i, M m, Y", $lasttime)."</td> <td>$regtime<br>".date("H:i, M m, Y", $regtime)."</td> </tr>"; } echo "</table>"; } displayUsers(); include("footer.php"); ?>
  16. I found this bit of code in an example script that seems to use strlen as a function that outputs true or false: if (!$item || strlen($item = trim($item)) == 0) { ... Is that code valid? For me, it seems to do what it's supposed to, determine if $item is set, but how does it actually do that? And... what is the use for trim here?
  17. I think I finally got this mess sorted out. Apparently != is just fine for mySQL . Thanks. This is the final code: $good = mysql_query("SELECT * FROM kana WHERE `group`='".$groups[$g]."' ORDER BY RAND() LIMIT 1") or die(mysql_error()); $good = mysql_fetch_array($good); $bad = mysql_query("SELECT * FROM kana WHERE `romaji`!='". $good['romaji'] ."' ORDER BY RAND() LIMIT 3") or die(mysql_error()); while ($r = mysql_fetch_array($bad)) { $badar[] = $r; }
  18. Ok, thank you. Now for the 3 random entries, I don't want the first entry to ever be selected, so what would be the "!=" equivalent for a mysql query? Also, I'm getting an error when I try to use WHERE in my query: $good = mysql_query("SELECT * FROM kana WHERE group=$g ORDER BY RAND() LIMIT 1") or die(mysql_error()); This usually doesn't happen, and wrapping any ", `, or 's around it seems to make it worse. Edit: For reference, when I take out the "WHERE group=$g" and print_r the array, I get... ( [0] => se [romaji] => se [1] => 3 [group] => 3 [2] => せ [hiragana] => せ [3] => セ [katakana] => セ )
  19. I have an array with many entries that contains the fields "romaji", "group", "hiragana", and "katakana". The field "group" contains a number between 1 and 11. What I want to do is create a script that can select a random entry with a specific "group" field, add it to a new array, and delete it from the main array. I then want to select three more random entries with no specific group (even if the group # is the same as the first entry), and add them to a new database. How would I be able to do that? I retrieve this array from a database, so if there's also a way I can do this directly from the database to two arrays, then please let me know. Thank you for your time.
  20. I'm writing a script that determines the time for a specified timezone. Here's the code for generating the time: <?php $offset = $hoursGMT + $timezone; if ($dst == "off") $offset++; $hoursoff = $offset; $offset = $offset * 60 * 60; if ($format == 24) { $hour = date("G", $offset); } elseif ($format == 12) { $hour = date("g", $offset); } $time = $hour . ":" . date(i) . ":" . date(s); $meridiem = date("A", $offset); ?> $hoursGMT is -8, the number of hours away from GMT (+00:00) time. $timezone is the pre-specified timezone, from -11 to 12. From those two variables, I can determine $offset, the seconds in the future or in the past that Yesterday, this code worked in what I'm pretty sure is the same code I have now, but it's been acting very messed up since this morning, displaying inaccurate hours. Which leads me to believe that something must've changed since yesterday, but I can't figure out what it is. Edit: It appears that now, in the afternoon, it's working normally again. Apparently there's only a problem when the server is in AM time.
  21. Ok, so I make a table that contains the names and IDs of the groups. Then I create a table that has an entry for every group any user has? So if two users had 6 groups selected, there would be 12 entries?
  22. I'm still a bit confused. There's a difference between a table and a log db, right?
  23. I'm creating a quiz/flashcard program with somewhere over a hundred questions. The questions are organized into groups of five or less, with each group having an ID. So my database for the questions is like: Question1 | Group# | Answer1 Question2 | Group# | Answer2 Question3 | Group# | Answer3 Et cetera... I'm planning on creating options in my settings page to let the user pick exactly what group he or she wants to receive questions from, and to have those settings saved on their account, in their account entry on the database. My problem is that I don't want to have to make a field for each group on my users table, because I'd then end up with dozens of fields. So is there any way I could define what groups I want to use in one field on a table? Thanks.
×
×
  • 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.