-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
<?php $code = "<a href=\"test\">test</a>tester"; $code = preg_replace("/\<a href=([^\[]+)\>(.*?)\<\/a\>/","",$code); $code .= '<img src="http://feeds.searchengineland.com/~r/searchengineland/~4/478232756" height="1" width="1"/>'; $code = preg_replace("/\<img src=([^\[]+)\>/","",$code); echo $code; ?> Prints out tester
-
$code = eregi_replace("\<a href=([^\[]+)\]([^\[]+)\</a\>","",$code); This might do it
-
[SOLVED] Wierd Validation errors, session ID
DeanWhitehouse replied to DeanWhitehouse's topic in PHP Coding Help
@rhodesa, if you look at the source it is not added by me. Hmm This .htaccess code gives me a 500 script error php_value session.use_only_cookies 1 php_value session.use_trans_sid 0 Looks like i will have to live with session id -
When running a w3 validation on my site i get some weird errors Validation Output: 23 Errors 1. Warning Line 71, Column 58: cannot generate system identifier for general entity "sid". …style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">PH ✉ An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (. The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs". Entity references start with an ampersand (&) and end with a semicolon (. If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters. If this error appears in some markup generated by PHP's session handling code, this article has explanations and solutions to your problem. Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed. 2. Error Line 71, Column 58: general entity "sid" not defined and no default entity. …style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">PH ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 3. Error Line 71, Column 61: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">PHP(7 ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 4. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 5. Error Line 71, Column 185: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=2&sid=f20710990deaf8aafc9b988c0a5f6bca">HTML( ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 6. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 7. Error Line 71, Column 310: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=3&sid=f20710990deaf8aafc9b988c0a5f6bca">CSS(0 ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 8. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 9. Error Line 71, Column 434: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=4&sid=f20710990deaf8aafc9b988c0a5f6bca">Javas ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 10. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 11. Error Line 71, Column 565: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=5&sid=f20710990deaf8aafc9b988c0a5f6bca">AJAX( ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 12. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 13. Error Line 71, Column 690: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=6&sid=f20710990deaf8aafc9b988c0a5f6bca">ASP(0 ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 14. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 15. Error Line 71, Column 842: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=7&sid=f20710990deaf8aafc9b988c0a5f6bca">Visua ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 16. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 17. Error Line 71, Column 975: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=8&sid=f20710990deaf8aafc9b988c0a5f6bca">Lite- ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 18. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 19. Error Line 71, Column 1102: reference to entity "sid" for which no system identifier could be generated. …le="font-size:16px;" href="?cat=9&sid=f20710990deaf8aafc9b988c0a5f6bca">C(0)< ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 20. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 21. Error Line 71, Column 1225: reference to entity "sid" for which no system identifier could be generated. …e="font-size:16px;" href="?cat=10&sid=f20710990deaf8aafc9b988c0a5f6bca">C++(0 ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 22. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 23. Error Line 71, Column 1350: reference to entity "sid" for which no system identifier could be generated. …e="font-size:16px;" href="?cat=11&sid=f20710990deaf8aafc9b988c0a5f6bca">C#(0) ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 24. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 25. Error Line 71, Column 1474: reference to entity "sid" for which no system identifier could be generated. …e="font-size:16px;" href="?cat=16&sid=f20710990deaf8aafc9b988c0a5f6bca">Java( ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 26. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 27. Error Line 77, Column 40: reference to entity "sid" for which no system identifier could be generated. <li><a href="code.php?snippet=12&sid=f20710990deaf8aafc9b988c0a5f6bca">Ajax ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 28. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 29. Error Line 77, Column 144: reference to entity "sid" for which no system identifier could be generated. …><li><a href="code.php?snippet=11&sid=f20710990deaf8aafc9b988c0a5f6bca">Ajax ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 30. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 31. Error Line 77, Column 246: reference to entity "sid" for which no system identifier could be generated. …i><li><a href="code.php?snippet=7&sid=f20710990deaf8aafc9b988c0a5f6bca">Basic ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 32. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 33. Error Line 77, Column 336: reference to entity "sid" for which no system identifier could be generated. …><li><a href="code.php?snippet=10&sid=f20710990deaf8aafc9b988c0a5f6bca">Simpl ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 34. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 35. Error Line 77, Column 434: reference to entity "sid" for which no system identifier could be generated. …i><li><a href="code.php?snippet=9&sid=f20710990deaf8aafc9b988c0a5f6bca">Basic ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 36. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 37. Error Line 92, Column 38: reference to entity "sid" for which no system identifier could be generated. <li><a href="snippet.php?cat=7&sid=f20710990deaf8aafc9b988c0a5f6bca">Visual ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 38. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 39. Error Line 92, Column 128: reference to entity "sid" for which no system identifier could be generated. …li><li><a href="snippet.php?cat=5&sid=f20710990deaf8aafc9b988c0a5f6bca">AJAX< ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 40. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 41. Error Line 92, Column 211: reference to entity "sid" for which no system identifier could be generated. …i><li><a href="snippet.php?cat=11&sid=f20710990deaf8aafc9b988c0a5f6bca">C#</a ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 42. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 43. Error Line 92, Column 292: reference to entity "sid" for which no system identifier could be generated. …i><li><a href="snippet.php?cat=10&sid=f20710990deaf8aafc9b988c0a5f6bca">C++</ ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 44. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 45. Error Line 92, Column 373: reference to entity "sid" for which no system identifier could be generated. …li><li><a href="snippet.php?cat=9&sid=f20710990deaf8aafc9b988c0a5f6bca">C</a> ✉ This is usually a cascading error caused by a an undefined entity reference or use of an unencoded ampersand (&) in an URL or body text. See the previous message for further details. 46. Info Line 71, Column 57: entity was defined here. … style="font-size:16px;" href="?cat=1&sid=f20710990deaf8aafc9b988c0a5f6bca">P 47. Warning Line 101, Column 122: NET-enabling start-tag requires SHORTTAG YES. …e="f20710990deaf8aafc9b988c0a5f6bca" /> ✉ The sequence <FOO /> can be interpreted in at least two different ways, depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/' terminates the tag <FOO (with an implied '>'). However, since many browsers don't interpret it this way, even in the presence of an HTML 4.01 Strict DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve its use solely for those written in XHTML. Yet my code contains none of the above, any ideas? Here is the validator link and the code http://validator.w3.org/check?uri=http%3A%2F%2Fdjw-webdesign.awardspace.com%2Fsnippet.php&charset=%28detect+automatically%29&doctype=Inline&group=0 <?php ob_start(); include 'Includes/header.php'; include 'Includes/nav.php'; if(isset($_GET['download']) && is_numeric($_GET['download'])) { $id = $_GET['download']; $id = stripslashes($id); $sql = "SELECT * FROM djw_snippet WHERE id = ".$id; $sql = mysql_query($sql); $count = mysql_num_rows($sql); if($count == 0) { header("Location:http://djw-webdesign.awardspace.com/snippet.php"); } else { $row = mysql_fetch_assoc($sql); $file = $row['file']; if(!file_exists("Files/".$file)) { $sq1 = "INSERT INTO djw_missing_file (file,ip) VALUES ('".$file."','".$_SERVER['REMOTE_ADDR']."')"; $sq1 = mysql_query($sq1); ?> <script type="text/javascript"> alert("The file you are trying to download cannot be found. This error has been reported to an administrator."); </script> <noscript> The file you are trying to download cannot be found. This error has been reported to an administrator.<br> You will now be redirected. </noscript> <meta http-equiv="refresh" content="3;url=http://djw-webdesign.awardspace.com/snippet.php"> <?php } else { $downs = $row['downloads'] + 1; mysql_query("UPDATE djw_snippet SET downloads = '$downs' WHERE id = '$id'"); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header( "Content-Disposition: attachment; filename=".basename($file)); header( "Content-Description: File Transfer"); readfile($file); } } } ?> <div id="wrapper"> <div id="page"> <div id="content"> <div class="post"> <h1 class="title">Code Snippets</h1> </div> <?php if(isset($_GET['cat']) && is_numeric($_GET['cat'])) { $cat = stripslashes($_GET['cat']); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM djw_snippet WHERE parent_id = '".$cat."'"; $result = mysql_query($sql); $r = mysql_fetch_row($result); $numrows = $r[0]; if($numrows != 0) { // number of rows to show per page $rowsperpage = 5; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if if($totalpages > 1) echo "<div class=\"post\"><h2 class=\"title\">Page $currentpage out of $totalpages</h2></div>"; // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT * FROM djw_snippet WHERE parent_id = '".$cat."' ORDER BY time DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql); // while there are rows to be fetched... while($rows = mysql_fetch_assoc($result)) { $cont = $rows['desc']; $cont = htmlentities($cont); $cont = nl2br($cont); $cont = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $cont); $cont = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $cont); $sql23 = mysql_query("SELECT * FROM djw_snippet_comments WHERE parent_id = '".$rows['id']."'"); ?> <div class="post"> <p class="byline"><a name="<?php echo $rows['title']."_".$rows['id']; ?>"></a><a href="http://djw-webdesign.awardspace.com/code.php?snippet=<?php echo $rows['id']; ?>"><?php echo $rows['title']; ?></a><br><small><?php if($rows['updated'] == 1){echo "Updated on ".date("F jS, Y",strtotime($rows['time']));}else{echo "Submitted on ".date("F jS, Y",strtotime($rows['time'])); }?> by <?php echo $rows['poster']; ?></small></p> <div class="entry"> <p><?php echo $cont; ?></p> <p class="links"><a href="?download=<?php echo $rows['id']; ?>" class="more">Download</a> <?php if($rows['example_sub'] == 1){?><a target="_blank" href="<?php echo $rows['example']; ?>" class="comments">Example</a><?php }else{echo "No Example";} ?> <a href="snippet_comment.php?comment=<?php echo $rows['id']; ?>" class="comments"><?php if(mysql_num_rows($sql23) == 0){echo "No Comments";}else{if(mysql_num_rows($sql23) > 1){$count = mysql_num_rows($sql23)." Comments";}else{$count = mysql_num_rows($sql23)." Comment";}echo $count;}?></a></p> </div> </div> <?php } /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?cat=".$cat."¤tpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?cat=".$cat."¤tpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { if($totalpages > 1) echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?cat=".$cat."¤tpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?cat=".$cat."¤tpage=$nextpage'>></a> "; if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?cat=".$cat."¤tpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ } else echo "No snippets yet.<br><a href=\"http://djw-webdesign.awardspace.com/snippet.php\">Back</a>"; } else { // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM djw_categories"; $result = mysql_query($sql); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 21; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if if($totalpages > 1) echo "<div class=\"post\"><h2 class=\"title\">Page $currentpage out of $totalpages</h2></div>"; // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT * FROM djw_categories WHERE approved = '1' ORDER BY id ASC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql); // while there are rows to be fetched... $i_l = 0; echo "<div class=\"post\">"; while($rows = mysql_fetch_assoc($result)) { $s = "SELECT id FROM djw_snippet WHERE parent_id = '".$rows['id']."'"; $s = mysql_query($s); $s = mysql_num_rows($s); if($i_l == 6) { echo "<br></div><div class=\"post\">"; $i_l = 0; } echo "<a style=\"font-size:16px;\" href=\"?cat=".$rows['id']."\">".$rows['name']."(".$s.")</a> "; $i_l++; } echo "</div>"; /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { if($totalpages > 1) echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ } ?> </div> <?php include 'Includes/sidebar.php'; include 'Includes/footer.php'; ?> It is long, but only because of the pagination And the source code <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- Design by Free CSS Templates http://www.freecsstemplates.org Released for free under a Creative Commons Attribution 2.5 License Name : Description Description: A three-column, fixed-width blog design. Version : 1.0 Released : 20071004 --> <html> <head> <script type="text/javascript"> function CreateBookmarkLink() { title = "DJW Webdesign - Code Snippets"; url = "http://djw-webdesign.awardspace.com/"; if (window.sidebar) { // Mozilla Firefox Bookmark window.sidebar.addPanel(title, url,""); } else if( window.external) { // IE Favorite window.external.AddFavorite( url, title); } else if(window.opera && window.print) { // Opera Hotlist return true; } } </script> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Dean James Whitehouse - Web Design</title> <meta name="verify-v1" content="4O3RDcqL15mGJ2FihdwQJdaoBSex1gZF4BVPfeVQRg8="> <meta name="keywords" content="3d avatar ,adult web design ,affordable web design ,agent web design ,ajax code ,art web design ,asm code ,asp code ,asp net code ,asp source code ,asp web design ,assembly source code ,austin web design ,award winning web design ,basic web design ,best web design ,best web design company, ,best web design templates, ,best website design, ,brochure design, ,builder website, ,business web design ,buy web design software ,c clock ,c code ,c help ,c questions ,c source code ,c# chat ,c# code ,c# code example ,c# code formatter ,c# code generator ,c# code samples ,c# code snippet ,c# code snippets ,c# coding ,c# example ,c# examples ,c# final ,c# forum ,c# forums ,c# help ,c# http post ,c# isnumeric ,c# language ,c# not all code paths return a value ,c# obfuscator ,c# programming ,c# samples ,c# source code ,c# source codes ,c ,c calculator code ,c code ,c code analysis ,c code analyzer ,c code example ,c code formatter ,c code snippets ,c codes ,c coding ,c example ,c example programs ,c examples ,c game code ,c game source code ,c games source code ,c link list ,c linked list ,c menu ,c sample programs ,c source code ,c source code formatter ,c source codes ,c split ,c static code analysis ,cheap web design ,cheap web design programs ,cheap website design ,cheap websites ,chesapeake web design ,chicago web design studio ,classes in web design ,code ,code computer programming ,code for vb net ,code organizer ,code ruby ,code ruby on rails ,code snippet ,code snippets ,codekeep ,codes vb net ,coding computer programming ,coding programming ,coldfusion code ,colleges for web design ,commercial web design ,company logo design ,computer programming discussion ,computer programming discussion forum ,computer programming help ,computer programming question ,computer programming questions ,content management system ,corporate logo design ,corporate web design ,create avatar ,create web page ,creative web design ,css design layout ,css web design templates ,custom web design ,custom web design ny ,custom website design ,delphi code ,delphi source code ,design ,design a website ,design company ,design layout tips web ,doevents vb net ,dot net source code ,download vb net ,dubai web design firm ,durango web design ,dynamic web design ,e commerce web design ,e commerce web hosting ,easy web design ,ecommerce web design ,ecommerce web hosting ,ecommerce website design ,flash design ,flash web design ,flash website design ,folderbrowserdialog vb net ,for python ,free asp code ,free vb code ,free vb net code ,free vb source code ,free visual basic ,free visual basic code ,free web design ,free web design software ,freelance web design ,freelance web designer ,frontpage web design ,getcwd c ,good web design ,google code prettify ,graphic design ,graphic design companies ,graphic design company ,graphic design logo ,graphic design services ,graphic design website ,graphic designer ,graphic designers ,graphic printing web design ,graphic web design ,great web design ,homepage design ,how to build a web page ,how to code c ,how to computer programming ,how to create a web page ,how to delphi ,how to make a web page ,how to programming ,html ,html code ,html coding ,html programming ,html snippet ,html source code ,html tutorials ,html web design ,interactive web design ,internet design ,internet marketing ,internet web design ,iowa web design ,jsp code ,la web design ,learn c# ,learn visual basic ,learn web design ,learning web design ,liverpool web design package ,liverpool web design packages ,logo design ,logo designs ,low cost web design ,marietta web design ,marin web design ,miami beach web design ,miami web design ,miami web design company ,musician web design ,mysqlforge ,net code ,net code snippets ,net licensing ,net obfuscate ,net obfuscation ,net obfuscator ,net source code ,novato web design ,open source ,open source c# ,open source c ,open source code ,open source coldfusion ,open source delphi ,open source programming ,open source visual basic ,orem web design ,pascal code ,pascal source code ,perl code ,perl source code ,personal web design ,petaluma web design ,php ,php calendar ,php code ,php coding ,php developers ,php development ,php experts ,php forum ,php forums ,php ide ,php language ,php programmer ,php programming ,php source code ,php syntax ,php web design ,professional design ,professional web design ,professional web design company ,professional web design studio ,professional website design ,programming code ,programming development ,programming discussion ,programming discussion forum ,programming help ,programming help forum ,programming online help ,projects c# ,python ,python change directory ,python code ,python forum ,python list files ,python sample code ,python source code ,real estate web design ,real estate website design ,realtor web design ,regina web design ,restaurant web design ,rohnert park web design ,roswell web design ,ruby source code ,sample code c# ,sample code c ,saskatchewan web design ,seo web design ,simi valley web design ,simple web design ,site design ,small business web design ,snippets ,snipplr ,software developer ,software development ,software development community ,software development forum ,software development help ,source code ,source code asp net ,source code library ,source code vb net ,source codes ,source codes visual basic ,sqrt c ,syntaxeditor ,tic tac toe c ,tic tac toe c code ,timer c ,top web design ,top web design companies ,tutorial html ,uae web design services ,usa web design ,vb code ,vb code library ,vb codes ,vb net ,vb net code ,vb net code examples ,vb net code generator ,vb net code help ,vb net code library ,vb net code project ,vb net code samples ,vb net code snippets ,vb net coding ,vb net programs ,vb net projects ,vb net sample code ,vb net source codes ,vb source code ,vb6 source code ,ventura county web design ,visual basic ,visual basic 2005 code ,visual basic 6 ,visual basic 6 code ,visual basic 6 source code ,visual basic access ,visual basic code ,visual basic code examples ,visual basic codes ,visual basic coding ,visual basic decompiler ,visual basic examples ,visual basic help ,visual basic how to ,visual basic language ,visual basic net ,visual basic net 2003 ,visual basic net code ,visual basic net source code ,visual basic programming ,visual basic programs ,visual basic sample code ,visual basic source ,visual basic source code ,visual c source code ,visual studio code snippets ,web authoring software ,web content management ,web content management system ,web design ,web design agency ,web design and development ,web design and hosting ,web design awards ,web design book ,web design buffalo ,web design by duhrkopf ,web design ca ,web design class ,web design classes ,web design companies ,web design company ,web design consultation ,web design consulting ,web design courses ,web design creation ,web design development ,web design directory ,web design examples ,web design firm ,web design firms ,web design flash ,web design flash templates ,web design forums ,web design graphics ,web design help ,web design honolulu ,web design hosting ,web design how to ,web design in dubai ,web design jobs ,web design naples fl ,web design oahu ,web design packages ,web design page layout ,web design price ,web design prices ,web design pricing ,web design quote ,web design rates ,web design school ,web design schools ,web design service ,web design services ,web design small business ,web design software ,web design solutions ,web design southern california ,web design studio ,web design study for free ,web design success ,web design teddington ,web design template ,web design templates ,web design tips ,web design tools ,web design training ,web design training course ,web design tutorial ,web designer ,web designers ,web designing ,web designing companies ,web designing company ,web designs ,web developers ,web development ,web development companies ,web development company ,web hosting ,web marketing ,web page create ,web page design ,web page design company ,web page design good ,web page design services ,web page design techniques ,web page design template ,web page design templates ,web page designers ,web page designing ,web page designs ,web services design ,web site design ,web site designers ,web site designing ,web site development ,web solutions ,web template ,web templates ,webpage design ,website builder ,website content management ,website content management system ,website design ,website design companies ,website design company ,website design prices ,website design pricing ,website design software ,website design template ,website designer ,website designers ,website designing ,website designs ,website developers ,website development ,website development companies ,website hosting ,website templates ,websites design "> <meta name="description" content="We are here to provide a reliable and quality web service. We can design and create your website for a low charge, and even mantain and host it if you wish. We charge reasonable prices for our quality service. We also offer help for web developers by offering free code snippets for most web lanaguages."> <meta name="author" content="Dean Whitehouse"> <meta http-equiv="cache-control" content="public"> <meta http-equiv="content-language" content="en-UK"> <meta name="copyright" content="© 2004 dean whitehouse"><link href="http://djw-webdesign.awardspace.com/default.css" rel="stylesheet" type="text/css" media="screen"> </head> <body> <!-- start header --> <div id="logo"> <h1><a href="http://djw-webdesign.awardspace.com/">DJW-Webdesign</a></h1> <p>For all your coding needs</p> </div> <div id="menu"> <ul id="main"> <li ><a href="http://djw-webdesign.awardspace.com/">Homepage</a></li> <li><a href="http://djw-webdesign.awardspace.com/blog.php">Blog</a></li> <li class="current_page_item"><a href="http://djw-webdesign.awardspace.com/snippet.php">Snippets</a></li> <li ><a href="http://djw-webdesign.awardspace.com/snippet_add.php">Submit Snippet</a></li> <li ><a href="http://djw-webdesign.awardspace.com/cat_creator.php">Create Category</a></li> <li ><a href="http://djw-webdesign.awardspace.com/search.php">Snippet Search</a></li> <li><a href="javascript:CreateBookmarkLink();">Bookmark Us</a></li> <li><a href="admin/">Admin</a></li> </ul> </div><div id="wrapper"> <div id="page"> <div id="content"> <div class="post"> <h1 class="title">Code Snippets</h1> </div> <div class="post"><a style="font-size:16px;" href="?cat=1">PHP(7)</a> <a style="font-size:16px;" href="?cat=2">HTML(1)</a> <a style="font-size:16px;" href="?cat=3">CSS(0)</a> <a style="font-size:16px;" href="?cat=4">Javascript(0)</a> <a style="font-size:16px;" href="?cat=5">AJAX(2)</a> <a style="font-size:16px;" href="?cat=6">ASP(0)</a> <br></div><div class="post"><a style="font-size:16px;" href="?cat=7">Visual Basic(0)</a> <a style="font-size:16px;" href="?cat=8">Lite-C(0)</a> <a style="font-size:16px;" href="?cat=9">C(0)</a> <a style="font-size:16px;" href="?cat=10">C++(0)</a> <a style="font-size:16px;" href="?cat=11">C#(0)</a> <a style="font-size:16px;" href="?cat=16">Java(0)</a> </div> </div> <div id="sidebar1" class="sidebar"> <ul> <li> <h2>Recent Snippets</h2> <ul> <li><a href="code.php?snippet=12">Ajax Pagination - Arrays</a></li><li><a href="code.php?snippet=11">Ajax Pagination - MySql</a></li><li><a href="code.php?snippet=7">Basic HTML</a></li><li><a href="code.php?snippet=10">Simple Contact Form</a></li><li><a href="code.php?snippet=9">Basic Login</a></li> </ul> </li> <li> <h2>Recent Blog Comments</h2> <ul> <li>No Comments Yet</li> </ul> </li> <li> <h2>Recent Snippet Comments</h2> <ul> <li>No Comments Yet</li> </ul> </li> <li> <h2>Recent Categories</h2> <ul> <li><a href="snippet.php?cat=7">Visual Basic</a></li><li><a href="snippet.php?cat=5">AJAX</a></li><li><a href="snippet.php?cat=11">C#</a></li><li><a href="snippet.php?cat=10">C++</a></li><li><a href="snippet.php?cat=9">C</a></li> </ul> </li> <li> </li> </ul> </div> <div id="sidebar2" class="sidebar"> <ul> <li> <form id="searchform" method="get" action=""> <div> <input type="text" maxlength="20" name="query" id="s" size="15" value=""> <br> <input type="submit" value="Search" id="x"> </div> </form> </li> </ul> </div> <div style="clear: both;"> </div> </div> <!-- end page --> </div> <div id="footer"> <p>©2008 All Rights Reserved. • Dean Whitehouse • Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a> • <a href="http://www.awardspace.com/?aid=MjUyNjI1MjQyNDE5" target="_blank" title="web hosting">Powered by AWARDSPACE.COM</a> • This site is best viewed using <a target="_blank" href="http://www.mozilla.com/en-US/firefox/"><!--<img border="0" alt="Spreadfirefox Affiliate Button" src="http://sfx-images.mozilla.org/affiliates/Buttons/firefox3/FF3o80x15_square.gif" />-->Firefox</a></p> </div> </body> </html>
-
@DarkWater, yes and i hope you know you can still use PHP to get what you want from it
-
Use PHP mailer, or i believe there is a PEAR package.
-
Ok, then to save work i would add error_reporting(0); instead of suppressing each one on its own.
-
You know using @ to suppress errors isn't very good coding practice, you should fix any errors or alerts etc.. there might be. Or on live sites i use customer errors and error_reporting(0); to turn errors off, but i still try and fix any other errors there might be.
-
I was hoping you could at least work out some of it. What you do is then use mysql_num_rows(); to find out if you are there friend, then use an IF statement.
-
In the query use $sql = "SELECT * FROM table WHERE member_id = 'member_id_number' AND friend_id = 'friend_id_number'";
-
Only other thing i can suggest is using maybe an iframe or ajax and then view-source:http://www.website.com using a regex to find certain bits you want which you would surround in either certain tags or comments.
-
Are you serious?? Its an advertisement for Firefox, have you tried viewing it in other browsers, it looks exactly the same.
-
Also if it is a JS error then this is the wrong forum
-
Lol, sorry no. i put in static numbers so it would be easier to understand the actual values are dynamic. I believe i have fixed it, this is the current function <?php function work_out_yr_status($started,$duration,$i) { $started = strtotime($started); $start_month = date("n",$started); $start_year = date("Y",$started); $current_month = date("n"); $current_year = date("Y"); $yr_duration = $duration; $end_month = 6; $yr_difference = $current_year - $start_year; if($yr_difference > $yr_duration && $current_month > $end_month) { echo "Course completed in "; echo $start_year + $yr_duration; } elseif($yr_difference == $i && $current_month >= $start_month || $yr_difference == $i && $current_month <= $end_month) { echo "In progress"; } else echo "Not started"; } ?> And my loop to run it <?php for($i = 1;$i <= $program[0]['length'];$i++) { work_out_yr_status($details['started'],$program[0]['length'],$i); echo "Year ".$i."<hr align=\"center\">"; $member -> get_program_units($id,$i); echo "<br><br>"; } ?>
-
I am trying to find out whether a student is still on a course with this function i wrote <?php function work_out_yr_status($started,$duration) { $started = strtotime($started); $start_month = date("n",$started); $start_year = date("Y",$started); $current_month = date("n"); $current_year = date("Y"); $yr_duration = $duration; $end_month = 6; $yr_difference = $current_year - $start_year; for($i = 0;$i <= $yr_duration;$i++) { if($yr_difference > $yr_duration && $current_month > $end_month) { echo "Course completed in "; echo $start_year + $yr_duration; } elseif($yr_difference == $i && $current_month >= $start_month)//first academic year and before new year { echo "first academic year and before new year"; } elseif($yr_difference == $i && $current_month <= $end_month) { echo "first academic year and after new year"; } } } ?> How ever this prints out "first academic year and before new year", which i think is correct, but i need it to do this Year 1 - completed Year 2 - in progress Year 3 - not started This is a for loop i use <?php for($i = 1;$i <= 2;$i++) { work_out_yr_status("2007-09-05 19:31:11",2); echo " Year ".$i."<hr align=\"center\">"; $member -> get_program_units($id,$i); echo "<br><br>"; } ?> It prints out Obviously the text and display i can do , but i can't think of the logic for the function. Any help please
-
your query is wrong, use or die(mysql_error()); to find these things out, it should be $sql = "SELECT * FROM employees where username = '$username'"; or $sql = "SELECT * FROM employees where username = '".$username."'";
-
myaccount.php?username Bad idea, could end up leaving security gaps, best to just have myaccount.php And use a session to get the db data
-
For my site i just use a included file in all pages that checks the DB or flat file to see if the site is closed, if so then redirect all page requests to a certain page (unless logged in) and show them the reason it is closed.
-
pagination <help I knew nothing about it> !!
DeanWhitehouse replied to samoi's topic in PHP Coding Help
http://www.phpfreaks.com/tutorial/basic-pagination -
In the second loop try changing row to rows or do this to the first one.
-
[SOLVED] add 100 gold each time a user registers **simple**
DeanWhitehouse replied to berry05's topic in PHP Coding Help
No! Replace the variable $q with $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date,gold) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() ,'100')"; -
[SOLVED] Need Some Help with a login System
DeanWhitehouse replied to jnerotrix's topic in PHP Coding Help
Tutorials - (kinda) http://djw-webdesign.awardspace.com/code.php?snippet=9 http://djw-webdesign.awardspace.com/code.php?snippet=4 -- very basic tizag.com/php w3schools.com -
[SOLVED] add 100 gold each time a user registers **simple**
DeanWhitehouse replied to berry05's topic in PHP Coding Help
This line $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )"; just needs to include the gold row, you should be able to do that yourself, but just in case here it is $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date,gold) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() ,'100')"; -
So far i have this code to get a students grade from a table, but it has to go through about 4-5 tables to get all the relevant data for getting the grade. Is there a better way to structure my code instead of using lots of $_GET's. My code (cut out db connection, sessions start and html code) <?php $sql = mysql_query("SELECT * FROM students WHERE PSN = '".$_SESSION['PSN']."' AND DOB = '".$_SESSION['pass']."' LIMIT 1");//Run a query to list find the student details using his PSN and DOB to locate him/her, limited to 1 to stop any possible errors. $rows = mysql_fetch_assoc($sql);//get the row with the user details in echo "<h1>Welcome <a href=\"?logout\" title=\"Logout\">".ucfirst($rows['Name'])." ".ucfirst($rows['Surname'])."</a></h1>";//echo out there first and second names as the logout link echo "<h3>Login Details</h3>"; echo "<h5>PSN: ".$rows['PSN']."<br>Password: ".$rows['DOB']."</h5>";//echo out there PSN and DOB ?> <hr align="center"> <?php $sql = mysql_query("SELECT * FROM student_program WHERE PSN = '".$_SESSION['PSN']."'");//find the programs the student is on $row = mysql_fetch_assoc($sql);//get the rows of the programs if(isset($_GET['prog_id']))//if the url contains ?prog_id then store the value as a number inside the var $prog_id $prog_id = (int) stripslashes($_GET['prog_id']);//get the value and make it a number (stops them using invalid values) and stripslashes else//if they havent selected a program then use the default one $prog_id = $row['program_id'];//place the value of the row program_id into the var if(mysql_num_rows($sql) == 1)//If they are on one program then do { $sql1 = mysql_query("SELECT * FROM program WHERE id = '".$prog_id."' LIMIT 1");//Get the program they are on $rows = mysql_fetch_assoc($sql1); echo $rows['name'];//print the program name } if(mysql_num_rows($sql) > 1) { ?> <select name="prog_id" onChange="document.location = '?prog_id='+this.value;"><!-- Begin creating the the drop down list --> <?php $sql = mysql_query("SELECT * FROM student_program WHERE PSN = '".$_SESSION['PSN']."'");//get the student program details again while($row = mysql_fetch_assoc($sql))//perform a while loop, to go through each row that mathces the query criteria { $sql1 = mysql_query("SELECT * FROM program WHERE id = '".$row['program_id']."'");//Generate sql query getting program data related to the program_id. while($rows = mysql_fetch_assoc($sql1))//run through all the rows for the program data { ?> <option onClick="document.location = '?prog_id='+this.value;" value="<?=$rows['id'];?>"><?=$rows['name'];?></option> <?php //generate the drop down items fill using the program data. } } ?> </select> <?php $sql = mysql_query("SELECT * FROM program WHERE id = '".$prog_id."' LIMIT 1");//Run query to find the current program being viewed $rows = mysql_fetch_assoc($sql);//get the row echo " ".$rows['name'];//print the name on screen } echo " - "; $length = $rows['length'];//get the length of the course if($length > 1) echo $length." years"; else echo $length." year"; ?> <hr align="center"> <?php if(isset($_GET['unit_id']))//if the unit id is inputted then { $unit_id = (int) stripslashes($_GET['unit_id']);//make sure it is a number $sql = mysql_query("SELECT * FROM criteria WHERE unit_id = '".$unit_id."'");//Run the query to find the criteria relating to the unit if(mysql_num_rows($sql) == 0)//if there are no criteria, echo echo "No criteria for this unit."; else { if(isset($_GET['crit_id']))//If the criteria id is submitted then { $crit_id = (int) stripslashes($_GET['crit_id']);//Make it a number $sql = mysql_query("SELECT * FROM student_grade WHERE criteria_id = '".$crit_id."' AND PSN = '".$_SESSION['PSN']."' AND unit_id = '".$unit_id."' AND program_id = '".$prog_id."' LIMIT 1");//run the query to find the student grade relating to the program,unit and criteria if(mysql_num_rows($sql) == 0)//If there is no results then echo echo "No grade submitted yet"; else { $rows = mysql_fetch_assoc($sql);//store the rows echo "Status: ".$rows['grade']."<br> Comment: ".$rows['comment']."<br>"; //echo comments and grades } } else//if there is no criteria id submitted then { while($rows = mysql_fetch_assoc($sql))// list criteria for the unit { echo "<a href=\"?prog_id=".$prog_id."&unit_id=".$unit_id."&crit_id=".$rows['id']."\">".$rows['name']."</a> ".$rows['description']."<br>"; } } } } else//if there is no unit id submitted { for($i = 1;$i <= $length;$i++) { echo "Year ".$i."<hr align=\"center\">"; $sql = mysql_query("SELECT * FROM units WHERE program_id = '".$prog_id."' AND year = '".$i."'");//get units if(mysql_num_rows($sql) == 0) echo "No units for this program/year yet"; else { while($rows = mysql_fetch_assoc($sql))//list all units related to the program { echo " <a href=\"?prog_id=".$prog_id."&unit_id=".$rows['id']."\" title=\"Grades\">".$rows['name']."</a> ".$rows['description']."<br>"; } } echo "<br><br>"; } } ?>