Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. You do realise this thread is about 5 years old.
  2. Make sure the browser is loading the javascript/validationScript.js file. To check this when you run the code above press F12 should bring up the Web Inspector or Development Tools. Click the console tab and refresh your page. If your browser cant find the javascript file you should see an error message logged. Also this is bad way of handling sessions as <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>New directory page</title> <script src="javascript/validationScript.js"></script> </head> <?php session_start(); session_start() should be called before any output is sent the browser, this includes text,html,white space etc. Should be on first line of any .php file that uses sessions.
  3. You still need to use some form of loop. You need to add extra logic in your loop in order for x amount of columns to be outputted in a row. Have a look at link below for examples. http://forums.phpfreaks.com/topic/11572-multi-column-results/
  4. The comparison is happening here if(!isset($dump_file_content[$property_ref])){ I'm guessing somewhere else in the script it is loading up the current data from the database into $dump_file_current_content array, and the new xml data into the $dump_file_content array. The above line is checking if the database data is still in the xml data. If it isn't then it'll delete the property from the database.
  5. this is not right <?php echo <table id='display' width=548 border=0 summary="">?> It should be ?> <table id='display' width=548 border=0 summary=""> Your code is messy and hard to read, but thats probably the forum.
  6. PHP is not aware what your browser is. Your web browser sends a request to the server, the server pushes that request to the PHP interpreter which executes your php code and sends the result back to the server. The server passes this back to the browser. the browser parses the HTML/CSS//whatever and renders the page. PHP code never gets executed at the browser level, browser compatibility should not be an issue. Does everything else work with your app apart from the login form? How are you processing the login form, what is the html for your login form.
  7. The curly braces { and } do not match up. This could be what is causing the parse error. The brace is see that doesn't matchup is highlighted bellow: $extension = end($temp); { <--- THIS DOES NOT MATCH UP WITH A } if ($_FILES["file"]["error"] > 0) That could be the issue. A good tip to making sure the braces matches up is to always indent your code example for(someting) { if (condition) { // do something } else { if (condition) { // true } else { // false } } } Notice how each opening { and closing } brace all match up. It makes the code more easier to read and identify an issues like this.
  8. What/where is your date field? How is the date stored in your database? Functions you'll want to look at are date and/or strtotime (depening on how you're storing the date).
  9. Yeah that will help. Its hard to tell from the snippet of code you posted.
  10. When the form is submitted you need to compare the posted value to the value you're making in your for loop. If the values match add a selected attribute to the <option> tag. <form action="" method="post"> <select name="newgameday"> <? $startTime = mktime() - (2 * 3600); $endTime = mktime() - (14 * 24 * 3600); for ($i = $startTime; $i >= $endTime; $i = $i - 86400) { $thisDate = date('l F jS Y', $i); // nothing selected by default $selected = ''; // if the form is submitted. // Check that the posted value is the same as this value // if is the same set it to selected. if(isset($_POST['newgameday']) && $_POST['newgameday'] == $thisDate) $selected = ' selected'; // added the selected attribute here \/ print "<option value=\"$thisDate\"$selected>$thisDate</option>\n"; } ?> </select> <input type="submit" name="submit" value="Submit" /> </form>
  11. The block of code you have posted is valid html/php code. There are no errors on its own Its most like how you're implementing that code in your scripts. To get that error you're most likely just dumping it into the <?php ?> tags. like <?php <table> ... </table> ?> You cannot just dump html code inside PHP tags. PHP cannot parse html code. You need to either echo it out. Or go in and out of PHP mode. Example <?php //your php code here // no break out of php mode and display table ?> <table> ... </table> <?php // break into php mode again ?>
  12. mod_rewrite maps fake urls to ones that do exist (your existing urls). products/ is not a folder it is just a unique identifier that is captured by mod_rewrite. Whats follows after products/ is sent to view_product_page. It sets the query string variable product to that value. Create a file called test_page.php Now in add the following code to it <?php if(isset($_GET['message'])) echo 'Message is: ' . $_GET['message']; ?> <p> Try me out<br /> <a href="/test_page.php?message=hello+world">existing url</a><br /> <a href="/test/hello+world">clean url using mod_rewrite</a><br /> </p> Now in an .htaccess file (that is full name of the file) add this to it. make sure its in same folder as test_page.php RewriteEngine On RewriteRule ^test/([a-z0-9_\-\+]+)/?$ test_page.php?message=$1 [NC,L] Have a read of this article http://www.sitepoint.com/guide-url-rewriting/ it'll help you more than I can explain it.
  13. What is OB? What ini file. Your question doesn't make sense.
  14. You'll need to do a loop within a loop and have a nested list. Example code <div class="content archive"> <h3><?php echo _("Archive"); ?></h3> <ul> <?php $startDate = strtotime('2011-10-01'); $endDate = strtotime(date('Y-m-d')); $startYear = date('Y', $startDate); $endYear = date('Y', $endDate); // loop through years for($year = $startYear; $year <= $endYear; $year++) { // calcuate start/end months $startMonth = ($year == $startYear) ? date('m', $startDate) : 1; $endMonth = ($year == $endYear) ? date('m', $endDate) : 12; $class = "archive$year"; $url = URL . "blog/archive/love/$year/"; // make new list item for year, enclose new list for months in year echo " <li>\n <a href=\"$url\">$year</a>\n <ul class=\"$class\">\n"; // loop through months for($month = $startMonth; $month <= $endMonth; $month++) { $_month = date('F', mktime(0, 0, 0, $month, 1, 0)); ?> <li class="archiveLink"> <p><a href="<?php echo URL . "blog/archive/love/$year/$month" ?>"><?php echo _($_month); ?><span>ยป</span></a></p> </li> <?php } // end enclosed month list echo " </ul>\n </li>\n"; } ?> </ul> </div>
  15. You don't define a mod_rewrite rule for every product. You'd define your rule using regex. example rule RewriteRule ^product/([a-z0-9_\-]+)/?$ view_product_page.php?product=$1 The above rule will match urls like site.com/product/chocote-bar/ site.com/product/samsung_tvs/ ... etc mod_rewrite will map those urls to the following urls site.com/view_product_page.php?product=chocolate-bar site.com/view_product_page.php?product=samsung_tvs In view_product_page.php the superglobal variable $_GET['product'] will get the product from the url.
  16. No the = in the <?= tags is not the same as the assignment operator. It is just short hand syntax for <?php echo The isset isset($_POST['submitted']) ? "sorted by {$sortType}" : "unsorted"; The above Is returning the string "sorted by {$sortType}" if $_POST['submmited'] exists. If it doesn't exist the string "unsorted" is returned. The <?= tag will echo out the string returned.
  17. When you click on View New Content button what search critierior is selected (highlighted in purple) on the left column under the headings By content type, By time period and Other.
  18. The code will be very similar to your edit script. And Example delete link would be echo '<a href="delete.php?id="'.$row['your_entry_id_col'].'">DELETE </a>'; Example delete.php code // connect to mysqli $mysqli = msqli_query('localhost', 'usernmae', 'password', 'database'); // check that id is present in the url and id has only number characters if(isset($_GET['id']) && preg_match('~[0-9]+~', $_GET['id'])) { // get the id $id = $_GET['id']; // execute the query mysqli_query('DELETE FROM table_name_here WHERE entry_id_col=' . $id); // Check that the query deleted the entry if(mysqli_affected_rows ($mysqli) == 1) { echo 'Entry deleted!'; echo '<a href="admin.php">Go Back</a>'; } } The above example can only delete one entry at a time. If you want to be able to delete multiple entries at a time then you'd use checkboxes. Example code for this would be echo '<iput type="checkbox" name="delete[]" value="'.$row['your_entry_id_col'].'" />'; Example code to process the checkboxes in your edit script // connect to mysqli $mysqli = msqli_query('localhost', 'usernmae', 'password', 'database'); // check that any delete selections have been made if(isset($_POST['delete']) && (is_array($_POST['delete']) && !empty($_POST['delete'])) { // this holds valid values to be used in your query $valid_is = array(); // make sure the submitted ids only contain number characters // this is to make the query safe to use latter on foreach($_POST['delete'] as $id) { if(preg_match('~[0-9]+~', $id) { $valid_ids[] = $id; } } // if we have valid values if(is_array($valid_ids)) { // prepare query format $sql = 'DELETE FROM table_name_here WHERE entry_id_col IN (%s)'; // populate query with ids $sql = sprintf($sql, implode(',', $valid_ids)); // execute query mysqli_query($sql); // check that query deleted any records if(mysql_affected_rows($mysqli)) { echo 'Seletected entries have been deleted!'; echo '<a href="admin.php">Go Back</a>';// link back to admin page } } else { echo 'Sorry ids invalid cannot continue'; } } Above code is untested and is to only serve as an example.
  19. Are you wanting to delete from your admin page?
  20. Simple answer no. You can not reliably detect when the browser window is closed. The server only parses PHP files when they are requested.
  21. PDO works fine with while loop look at example #2 on PDO fetch method. What is your implementation of PDO?
  22. Can't see why in that code that is happening as I have tested but cannot reproduce the results. Wouldn't it be better to format the text when you get the data out from the database. How is $rows defined?
  23. So better to do // check that form has been submitted if(isset($_POST['submit'])) { // check if no errors if(isset($_FILES['file']['error']) && $_FILES['file']['error'] == 0) { //... process upload here ... } else { echo "Error" . $_FILES["file"]["error"]; } }
  24. Do note though that the <?= ?> tags will only work if short_open_tag directive is enabled in the php.ini file. Not all servers will have this setting enabled and/or allowed to be changed. Using full PHP tag syntax is recommend (as kicken showed you above).
  25. It was just an extra check before processing the file upload. The _FILES superglobal array only exists when the file upload form has been submitted successfully. We don't want to process the upload if the file didn't get uploaded for some reason.
×
×
  • 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.