Jump to content

Spaceman-Spiff

Members
  • Posts

    52
  • Joined

  • Last visited

    Never

Everything posted by Spaceman-Spiff

  1. I made a test page: http://opdb.info/dom/dom.html The HTML itself is valid XHTML 1.0 Transitional. The JavaScript is also valid, press F12 to enable Firebug Lite to check. However, when you check the HTML output generated by the JavaScript DOM, it's not XHTML. The output looks even worse in IE. It still looks like HTML 4 valid in Firefox. Again, this is a trivial thing, since the page itself is still valid, but it rouses my curiosity. souce code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DOM Test page</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="Stylesheet" type="text/css" href="styles.css" /> <script type="text/javascript" src="firebug/firebug.js"></script> </head><body> <h2>This page is Valid XHTML 1.0 Transitional!</h2><br /> <div id="printhere" class="debugbox"></div><br /> <a href="" onclick="alert(document.getElementById('printhere').innerHTML);">Check above HTML code</a> <script type="text/javascript"> //create checkbox - Method 1: using setAttribute() var inputbox = document.createElement("input"); inputbox.setAttribute("id", "text1"); inputbox.setAttribute("name", "text1"); inputbox.setAttribute("type", "checkbox"); document.getElementById('printhere').appendChild(inputbox); //create image - Method 2: using object properties var image = document.createElement("img"); image.id = "newimage"; image.src = "http://www.w3.org/Icons/w3c_main"; image.alt = "W3C Logo"; document.getElementById('printhere').appendChild(image); </script> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" border="0" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" border="0" /></a> </p> </body></html>
  2. The page itself (html) is still xhtml compliant if you code it so. However, the generated (on-the-fly) elements that are created via JavaScript, are not XHTML compliant. Try this code for example: var newdiv = document.createElement('div'); inputbox = document.createElement("input"); inputbox.setAttribute("id", "text1"); inputbox.setAttribute("name", "text1"); inputbox.setAttribute("size", "4"); inputbox.setAttribute("type", "checkbox"); newdiv.appendChild(inputbox); alert(newdiv.innerHTML); The output in FF 2.0: <input size="4" name="text1" id="text1" type="checkbox"> Output in IE 7: <INPUT id=text1 type=checkbox size=4> (a lot uglier) PS: This is just a trivial matter, as the page itself will still be xhtml compliant. However, I'm just curious if such result can be obtained. PPS: createElementNS() does the same thing.
  3. Is it possible to use DOM to output XHTML (instead of HTML)? Example: formfield = document.createElement("input"); formfield.setAttribute("size", "4"); formfield.setAttribute("name", "text1"); formfield.setAttribute("id", "text1"); formfield.setAttribute("type", "text"); Will output: <input id="text1" name="text1" size="4" type="text"> Prefered output: <input id="text1" name="text1" size="4" type="text" /> It's trivial, but just curious...
  4. Your while loops look odd. I would do it this way if I were you: <?php mysql_connect("***", "***", "***") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $query1 = "SELECT * FROM sticky"; $query2 = "SELECT * FROM news"; $result1 = mysql_query($query1) or die(mysql_error()); $result2 = mysql_query($query2) or die(mysql_error()); while($row1 = mysql_fetch_array($result1)) printNews($row1); while($row2 = mysql_fetch_array($result2)) printNews($row2); function printNews($news) { echo ' <table><tr> <td><h2><u>' . $news['title'] . '</u></h2></td> </tr><tr> <td>' . $news['news'] . '</td> </tr></table><br />'; } This will print all stickies, then all news (if that's what you're actually trying to do)
  5. By using regex, you can do pattern matching. It's a much more powerful tool than simple str_replace. Some bb codes can be replaced directly using str_replace, for example for [ b ] or [ /b ] to < b > and < /b >. But for something more complex, like involving attributes, you will need to use regex. For example [ url=http://urllink.com ] text [ /url ]. A simple str_replace won't do.
  6. It all depends on how the program/script works... For example, for this forum (SMF), you can record the actions by the "action" in the url (get method). Like: action=post, action=register, and so on... Different program works differently, I can't tell you how to do something I don't know about...
  7. The variable $id has never been defined. Perhaps you can use if, else method instead, it's simpler. <?php add_header(); db_connect(); $query =" SELECT artist_id, artist, description FROM artists WHERE artist_id = '$artistid' "; $result = mysql_query($query); $row = mysql_fetch_array($result); if (!empty($row['artist'])) { echo 'Welcome to the page of ' . $row['artist']; } else { echo 'Artist ID not found'; } ?>
  8. You should learn some basic PHP & MySQL if you want to do something like this. http://www.google.com/search?q=php+tutorials
  9. You can use str_replace() function, or if you want to put number to all the alphabet letters, you can use ord() instead.
  10. We're starting a new project at work, the team only consists of 2 programmer (me and the other guy). The other guy's background is Java and PHP5. My background is more varied from Basic, Pascal, VB, Java, C++, C#, PHP 3, 4, and now starting 5. I have never really coded anything in fully OO in PHP5, aside from modifying/tweaking codes. So far all of my past PHP projects have been procedural. It's the fastest way to code for me. Now, for this project, my co-worker wants everything coded in pure OO. No global variables/declarations at all. It's a decent-sized project with 2-3 months development time. I don't mind to start learning about OO in PHP5, but my main concern is coding in OO style may mean longer development time. Another concern is the code may not perform as fast as it would if coded procedurally. His main argument is coding in OO will make the project more extensible. From my past experiences with Java and C#, OO codes tends to be longer (more total lines of code), thus also take longer to code. It is more "secure" and the code looks prettier (sometimes), is it always worth it? I have read the other topic about this. I do want feedback on this more specific matter.
  11. You can do some validation using strstr() function, for example: $data[2] = trim(substr($line,141, 55))."<br />"; if (strstr($data[2], "\*word*\") $data[2] = ''; Alternately, you can use the strpos() function, or preg_match() function for something more complex.
  12. I know it does, but I dislike the font spacing/size for Shift_JIS .
  13. You can do a simple test inside worth.php: if (empty($_POST['strpost'])) echo 'No strpost value found'; else echo htmlspecialchars($_POST['strpost']); And make sure your form has the correct action, method and field names.
  14. Thank you guys, for all your suggestions. I have now used the following queries after mysql_select_db for formfields: mysql_query("SET NAMES 'utf8'"); mysql_query("SET CHARACTER SET 'utf8'"); I have also converted the whole database (not just the tables) to utf8_general_ci collation. I'm not sure which one fixed the problem, but now formfields stores unicode characters correctly. The only problem now is to rewrite all the data that are already stored in formfields. Which is still less of a headache than before. I'm gonna attempt to write a conversion script or some sort... PS: I can't use EUC-JP or Shift-JIS because the website is a mix of English and Japanese.
  15. The key is using LIMIT x, y - where x is the row start, and y is the row amount per page. Example: - for page 1: SELECT * FROM tablename LIMIT 0 , 30 - for page 2: SELECT * FROM tablename LIMIT 30 , 30 - for page 3: SELECT * FROM tablename LIMIT 60 , 30
  16. Since you made an alias for manufacturer AS c, you should use c.column_name: SELECT c.manufacturers_id FROM manufacturers as c
  17. If I use those, any unicode input will turn into ???. There's clearly something wrong (or different) in FF. The funny thing is when there's nothing else on the script or not integrated with phpMyAdmin/SMF/vBulletin, the unicode text prints fine. But when integrated with another system, it prints unreadable text.
  18. According to php.net: date_default_timezone_set — Sets the default timezone used by all date/time functions in a script http://www.php.net/date_default_timezone_set So, it should be a yes.
  19. Syntax error here: $message = " echo "<center><font size=6 color=blue> Salt Lake City Expiring Training Report </font><br><font color=blue>If nothing is below there are no actions needed.</font></center><p>"; You didn't close the quote sign in $message
  20. The SQL query should be something like this: UPDATE answer SET a_rank = a_rank + $modifier WHERE a_id = $aid LIMIT 1; fill in $modifier with 1 or -1, $aid with the table ID.
  21. http://www.google.com/search?q=coldfusion+tutorial+access+database
  22. That means the column category_id does not exist in your categories table. Check your table layout/design again.
  23. What you need to use is not strstr(), but str_replace(); Also, $search and $replace have to be in array format.
  24. Err, don't make it print the event then... remove the whole while loop. And you can change the div to clickable (javascript onclick), make it to direct the user to a new page, and list the events there.
  25. It looks good. Does it work properly? I guess you will need to create a few accounts with different userlevels to test it...
×
×
  • 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.