PHP - Paging Script Not Working
Dear all,
I have code for paging The problem is, one of them do not work properly This is OK http://www.amec-berca.co.id/abi/index.php?action=past-projects This is not OK http://www.parnaraya.net/beta/index.php?link=news My question: Is there any issues about PHP/Apache version? or something else? I used this script very often, and no problem so far except this time FYI, the host server using Virtualmin version 3.89 Thanks Similar TutorialsI see several great PHP/MySQL paging systems on google, but how can I make a paging system when I'm just showing all images in a directory, not showing all images from a database? I have no idea how I could convert one of those mysql systems to work for my needs. Here is my code: <?php $columns = "4"; $count = "0"; echo '<div style="overflow:auto; width:500px; height:266px;"><table cellpadding="0" cellspacing="10">'; if ($handle = opendir('.')) { while (false !== ($image = readdir($handle))) { if ($image != "." && $image != ".." && $image != "index.php") { if (strlen($image) > 11) { $short = substr($image,0,11); echo '<td align="center"><a href="'.$image.'" title="'.$image.'"><img src="'.$image.'" width="100" height="100"><br><div style="overflow:auto; width:100px;">'.$short.'...</div></a></td>'; } else { echo '<td align="center"><a href="'.$image.'" title="'.$image.'"><img src="'.$image.'" width="100" height="100"><br><div style="overflow:auto; width:100px;">'.$image.'</div></a></td>'; } $count++; if ($count == 4) { echo "</tr><tr>"; $count = 0; } } } closedir($handle); } echo "</table></div>"; ?> This code shows all images in a directory, 4 per row. I'd really appreciate some help with adding a paging feature to this. Thank you so much for the help! so my database has a page number next to each field. What I need to know how to do is make it so that the paging number, ie being able to select the page, if greater than one, will display 1-whatever the highest page number is. does this make sense? any help is appreciated. Hi Everyone, I need help in paging, i have a form with a lot of text boxes and drop down boxes, i need to use paging "Next..1..2..3", Please someone help me with it, i tried some codes but didn't work out. Thanks RAM Hello, everyone. I am having some trouble figuring this out. I am trying to create a paging bar(so to speak) to display results by page number. Trying to get the paging bar to go as follows... Requested Page The resulting paging bar Page 1 1 2 3 4 5 Page 2 1 2 3 4 5 Page 3 1 2 3 4 5 Page 4 1 2 3 4 5 Page 5 4 5 6 7 8 Page 6 4 5 6 7 8 Page 7 4 5 6 7 8 Page 8 7 8 9 10 11 ...... This is what I have right now that I am trying to get to work. I have changed this so many times and been working on it for 2 days. I think I'm just confusing my self. This can't be that hard.. Code: [Select] <?php echo '<html>'; //---these values changed based on query---- $Page=$_GET["page"]; //the page number requested $AvailablePages=5; //number of pages available after the page requested //---calculations--- $StartPage=round($Page/5)*5; $EndPage=ceil($StartPage/5)*5 ; //the last page number to be displayed in paging if($StartPage<5) {$StartPage=1;} //just looking at variables echo 'page is: ' . $Page . '<br>'; echo '<br>Starting @: ' . $StartPage; echo '<br>Ending @: ' . $EndPage . '<br>'; //--create the paging bar-- $PagingBar=''; while($StartPage<=$EndPage) { if($Page==$StartPage) { $PagingBar=$PagingBar . $StartPage . ''; } else { $PagingBar=$PagingBar . ' <a href="test.php?page=' . $StartPage . '">' . $StartPage . '</a> '; } $StartPage++; } //---show the paging bar-- echo $PagingBar; echo '</html>'; ?> Any one no a simple way to create a numbering system for a basic comment system. Code: [Select] <body> <?php $commentsTable = "comments"; $comments = "SELECT * FROM $commentsTable"; $commentResults = mysql_query($comments); $commentRows = mysql_fetch_array($commentResults); ?> <div id="BodyWrapper"> <?php while($commentRows = mysql_fetch_array($commentResults)){?> <div id="comments"> <div id="CommentWrapper"> <div id="comment"> <div id="UserName"><? echo $commentRows['name'];?></div> <div id="UserComment"><? echo $commentRows['comment'];?></div> <div id="UserEmail"><? echo $commentRows['email'];?></div> <div id="PostDateTime"><? echo $commentRows['datatime'];?></div> </div> </div> </div> <?php } mysql_close(); ?> </div> </body> This is what i have, i want to create a limit of 5 comment but with nummber so you can view older posts. Hello everybody,
i have page called cat.php
$cat_name get the data submited from othe .php page see line 77
this page show records WHERE category='$cat_name' see line 78
i have 2 problems:
first problem: if i dont have this "where" condition, the sort function works fine see line 74
second problem: if i dont have this "where" condition, the paging function works fine see line from 108
here is my code
thank you very much for your help
Rafal
<html> <head> <title></title> </head> <body> <?php> include("config.php"); ?> <?php $verbindung1 = mysql_connect("$hoster", "$nameuser", "$password") or die ("connection error"); mysql_select_db("$basedata") or die ("database error"); $abfrage = "SELECT cat_id, cat_name FROM $table3 ORDER BY cat_name ASC"; $ergebnis = mysql_query($abfrage); $num = mysql_num_rows($ergebnis); ?> <table> <tr> <?php while ($row = mysql_fetch_object($ergebnis)) { ?> <td> <font face="Arial" size="2"> <form action="cat.php" method="post" name="cat_form" id="cat_form"> <input type="hidden" name="inp_cat_name" value="<?php echo $row->cat_name; ?>"> <input type="submit" value="<?php echo $row->cat_name; ?>"> </form> </font> </td> <?php } ?> </tr></table> <?php> include("config.php"); ?> <?Php try { $dbo = new PDO('mysql:host=db.abcdef.fr;dbname='.$basedata, $nameuser, $password); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } $page_name="cat.php"; // page name @$sort=$_GET['sort']; if(strlen($sort)>0 and !ctype_alnum($sort)) { echo "Data Error"; exit; } @$start=$_GET['start']; if(strlen($start) > 0 and !is_numeric($start)) { echo "Data Error"; exit; } $zero = ($start - 0); $limit = 20; // number of rows per page $this1 = $zero + $limit; $back = $zero - $limit; $next = $zero + $limit; $query2=" SELECT destination, stars, price FROM $table1 WHERE vis='yes'"; $count=$dbo->prepare($query2); $count->execute(); $nume=$count->rowCount(); ?> <font face="Arial" size="2">Sortieren nach:<br> <?php echo "<a href='$page_name?sort=destination'>Zielort</a>"; ?> | <?php echo "<a href='$page_name?sort=stars'>Sterne</a>"; ?> | <?php echo "<a href='$page_name?sort=price'>Preis</a>"; ?><br><br> </font> <?php $cat_name = $_POST["inp_cat_name"]; $query=" SELECT * FROM $table1 WHERE category='$cat_name'"; if(isset($sort) and strlen($sort)>0){ $query = $query . " order by $sort"; } $query = $query. " limit $zero, $limit "; foreach ($dbo->query($query) as $row) { ?> <table cellspacing="0" cellpadding="0" border="1" width="600px" class="table"> <tr> <td rowspan="2" valign="top" class="td"> <img src="<?php if ($row[photo1] != '') { ?><?php echo $row[photo1] ?><?php } ?><?php if ($row[photo1] == '') { ?><?php echo 'cloud/500x282.gif' ?><?php } ?>" width="200" height="113"> </td> <th width="400px" class="th"><font face="Arial" size="2"><b><?php echo $row[product] ?></b> <?php if ($row[stars] == "1") { ?><?php echo "<img src='cloud/star.png'>"; } ?> <?php echo $row[destination] ?> (<?php echo $row[category] ?>)</font></th> </tr> <tr> <td valign="top" class="td" style="padding:7px;"> <font face="Arial" size="2"> <?php echo $row[shortdesc] ?><br> from <font size="4"><b><?php echo $row[price] ?> €</b></font> <font face="Arial" size="1">Nr. <?php echo $row[inventar] ?></font><br> <br> </font> </td></tr> </table> <br> <?php } if($back >=0) { echo "<a href='$page_name?start=$back&sort=$sort'><font face='Verdana' size='2'>back</font></a>"; } echo " "; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $zero){ echo " <a href='$page_name?start=$i&sort=$sort'><font face='Verdana' size='2'>$l</font></a> "; } else { echo "<font face='arial' size='2' color='black'>$l</font>";} $l=$l+1; } echo " "; if($this1 < $nume) { echo "<a href='$page_name?start=$next&sort=$sort'><font face='Verdana' size='2'>next</font></a>";} ?> </body> </html> Guys i badly need need to add paging in this . 20 records per page how to accomplish ? Code: [Select] <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $http = 'myurl.com/other.php?like=' ; $conn=odbc_connect('apple','',''); if (!$conn) {exit("Connection Failed: " . $conn);} $sql="SELECT * FROM mytable "; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Error in SQL");} echo "<table border= 1><tr>"; echo "<th>ID</th>"; echo "<th>Like</th>"; echo "<th>title</th></tr>"; while (odbc_fetch_row($rs)) { $ids=odbc_result($rs,"ID"); // $links=odbc_result($rs,"links"); $title=odbc_result($rs,"title"); echo "<tr><td>$ids</td>"; echo "<td><fb:like href=\"{$http}{$ids}\" layout=\"button_count\" show_faces=\"false\" width=\"100\" font=\"tahoma\" colorscheme=\"dark\"></fb:like> </td>"; echo "<td>$title</td></tr>"; } echo "</table>"; odbc_close($conn); ?> Hello everyone! I'm completely new to PHP and Databases. I've managed to do some nice work by reading, but now I've encountered a problem I can't solve. I made a site with trailers and got tierd of adding them manually. So I created a form which sends the trailer info to my database. There's now trailers in specific organized genres. But the list is beginning to get really big so I wanted to show just 10 trailers per page. And so I found out I could use a paging system which I ALMOST got working. Just one last thing that needs to be fixed and that is when I click on next page "http://www.xxxxxxxx.com/test.php&page=2" it doesn't show the content. While "http://www.xxxxxxxx.com/test.php" does. So I just need that next button to work, I don't know if theres something missing or what it is... Note: I'm new to all this so please excuse my very very bad coding. Here is my code: test.php <link rel="stylesheet" type="text/css" media="all" href="http://www.xxxxxxxxxxxxx.n.nu/createdfiles/trailers/style-twentyten.css" /> <link rel="stylesheet" type="text/css" media="all" href="http://www.xxxxxxxxxxxxx.com/paginate.css" /> <?php $rpp = 10; // results per page $adjacents = 4; $page = intval($_GET["page"]); if(!$page) $page = 1; $reload = $_SERVER['PHP_SELF']; // connect to your DB: $link_id = mysql_connect("server","username","my password"); mysql_select_db("database"); // select appropriate results from DB: $sql = "SELECT * FROM blablabla WHERE Genre LIKE '%Drama%' ORDER BY `blablabla`.`sort` DESC LIMIT 0, 9999"; $result = mysql_query($sql, $link_id); // count total number of appropriate listings: $tcount = mysql_num_rows($result); // count number of pages: $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number $count = 0; $i = ($page-1)*$rpp; while(($count<$rpp) && ($i<$tcount)) { mysql_data_seek($result,$i); $query = mysql_fetch_array($result); // output each row: echo "<br />--------------------------------------------------------------------------------------------------------<br /><br />"; ?><strong> <img src=" <?php echo $query['Poster'];?>" /><?php echo "<br /> <br />"; ////////////////////////////// //SHOW TITLE, YEAR AND GENRE// ////////////////////////////// echo "<H1>"; echo $query['Title']; echo "<br /> <br />"; echo "</h1>"; ?></strong> <?php echo "<H2>"; echo $query['Year']; echo "</H2>"; echo "<br />"; echo "<H3>"; echo $query['Genre']; echo "</H3>"; ?> <a href=" <?php ////////////////////////////// //SHOW IMDB, ACTORS AND PLOT// ////////////////////////////// echo $query['IMDB']; ?> " target="_self">Link to IMDb</a> <?php echo "<br /> <br />"; echo "<H2>Stars:</H2>"; echo "<br />"; echo "<H3>"; echo $query['Actors']; echo "</H3>"; echo "<br />"; echo "<H2>Plot:</H2>"; echo "<br />"; echo "<H3>"; echo $query['Plot']; echo "</H3>"; echo "<br /> <br />"; echo "<H2>"; //////////////// //SHOW TRAILER// //////////////// ?> <div id="<?php echo $query['ID'];?>" style="display: none;"> <?php echo $query['Youtube']; echo "</div>"; ?> <a href="javascript:ReverseDisplay('<?php echo $query['ID'];?>')">Click to show/hide trailer.</a> <?php echo "</H2>"; echo "<br /> <br />"; $i++; $count++; } // call pagination function: include("paginate_one.php"); echo paginate_one($reload, $page, $tpages); ?> <?php //////////////////////////////// //SCRIPT FOR SHOW/HIDE TRAILER// //////////////////////////////// ?> <script type="text/javascript" language="JavaScript"><!-- function HideContent(d) { document.getElementById(d).style.display = "none"; } function ShowContent(d) { document.getElementById(d).style.display = "block"; } function ReverseDisplay(d) { if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; } else { document.getElementById(d).style.display = "none"; } } //--></script> paginate_one.php <?php /************************************************************************* php easy :: pagination scripts set - Version One ========================================================================== Author: php easy code, www.phpeasycode.com Web Site: http://www.phpeasycode.com Contact: webmaster@phpeasycode.com *************************************************************************/ function paginate_one($reload, $page, $tpages) { $firstlabel = "First"; $prevlabel = "Prev"; $nextlabel = "Next"; $lastlabel = "Last"; $out = "<div class=\"pagin\">\n"; // first if($page>1) { $out.= "<a href=\"" . $reload . "\">" . $firstlabel . "</a>\n"; } else { $out.= "<span>" . $firstlabel . "</span>\n"; } // previous if($page==1) { $out.= "<span>" . $prevlabel . "</span>\n"; } elseif($page==2) { $out.= "<a href=\"" . $reload . "\">" . $prevlabel . "</a>\n"; } else { $out.= "<a href=\"" . $reload . "&page=" . ($page-1) . "\">" . $prevlabel . "</a>\n"; } // current $out.= "<span class=\"current\">Page " . $page . " of " . $tpages . "</span>\n"; // next if($page<$tpages) { $out.= "<a href=\"" . $reload . "&page=" .($page+1) . "\">" . $nextlabel . "</a>\n"; } else { $out.= "<span>" . $nextlabel . "</span>\n"; } // last if($page<$tpages) { $out.= "<a href=\"" . $reload . "&page=" . $tpages . "\">" . $lastlabel . "</a>\n"; } else { $out.= "<span>" . $lastlabel . "</span>\n"; } $out.= "</div>"; return $out; } ?> Here you can view a test of it all in action: http://www.mansgullberg.com/test.php please dont hack my site I'm thankfull for all of your answers! Really nice forum this! /kvickan Hi. I'm trying to make a sort of a forum, and this is the part of the code that needs to be changed, only I don't know how. Code: [Select] mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <table width='50%' border="0" align="center" cellpadding="3" cellspacing="1"> <?php $limit=10; $page=0; $numrows = mysql_num_rows($result); $pages = intval($numrows/$limit); if ($numrows % $limit) { $pages++;} $current = ($page/$limit) + 1; if (($pages < 1) || ($pages == 0)) { $total = 1;} else { $total = $pages;} $result = mysql_query("SELECT * FROM $tbl_name ORDER BY id DESC LIMIT $page,$limit"); while($rows=mysql_fetch_array($result)){?> <tr><td><font size="+2"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a><BR></font></td> <td width='0*'><? echo $rows['datetime']; ?></td></tr> <tr><td><? echo substr($rows['detail'], 0, 250)."..."; ?> <a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo "Citeste mai mult";} ?></a> </td></tr> <tr><tr><td> <? if ($page != 0) { // Don't show back link if current page is first page. $back_page = $page - $limit; echo("<a href=\"$PHP_SELF?query=$query&page=$back_page&limit=$limit\">back</a> \n");} for ($i=1; $i <= $pages; $i++) // loop through each page and give link to it. { $ppage = $limit*($i - 1); if ($ppage == $page){ echo("<b>$i</b>\n");} // If current page don't give link, just text. else{ echo("<a href=\"$PHP_SELF?query=$query&page=$ppage&limit=$limit\">$i</a> \n");} } if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { // If last page don't give next link. $next_page = $page + $limit; echo(" <a href=\"$PHP_SELF?query=$query&page=$next_page&limit=$limit\">next</a>");} ?> </td></tr></tr><?php mysql_close(); ?> </table> I made a database with 4 fields and 11 entries. The script shows the last 10 entries just as it should, but when I click on the 'next' button, nothing happens (it should show the first entry, but it just refreshes the page, and still the last 10 entries/1st page are shown). I think it has something to do with the link, but I can't figure out what exactly. Can someone help, or at least give me a hint? Thanks in advance. Bye. I have a list generated from an array by foreach as Code: [Select] foreach ($list_array as $item) { echo "$item<br />"; } This is a long list, how can I separate the list to different pages? I mean the simplest way to do so I'm very new to this and really could use some help. I've got a Web app that has one form that collects data from the user and puts it into a mysql database and has another form that allows the user to select critiera to find records in the database and display them on the page. All this is working just fine, but now that my database is getting more data in it, I want to add functionality to display 10 records on a page with results page navigation links so the user can move forward and backward in the results set. This part is not working and I've put in echo statements to figure out what the code is doing. The problem I'm having is that when the selection critiera pulls more than 10 records from the database, the first page of results is correct per the selection criteria entered by the user on the select form. When the 'next' link is selected to review the second page of results, the query is executed again. But this time the form variables have been reset and the results now contains the entire contents of the db. The start record is set to look at the 11th instance of the results set, so the second page starts with the 11th record in the database instead of the 11th record in the original results set. The original select statement is built by determining which criteria is selected using $_POST against each form variable. How can I retain the form variables or the original select statement so the second execution of the select statement results in the same results set as the first? The other option that may be better is to retain the original results set and avoid re-executing the select statement altogether. But I don't know how to do that either. Any suggestions, code samples or adivice is much appreciated! The following script doesn't seem to work? I re-used a registration script that I have which works fine, just changing the details where necessary but it doesn't work and shows no errors, when I fill out the form and click submit it just displays the form again, no success message, no error message and it doesn't add the info into the database, however when I run the same query through phpmyadmin it works... <?php include ('header.php'); ?></center> <div class=content> <?php if(!empty($_POST['username']) && !empty($_POST['password'])) { $fname = mysql_real_escape_string($_POST['first']); $lname = mysql_real_escape_string($_POST['last']); $email = mysql_real_escape_string($_POST['email']); $sia = mysql_real_escape_string($_POST['sia']); $no = mysql_real_escape_string($_POST['number']); $checknumber = mysql_query("SELECT * FROM staff WHERE no = '".$no."'"); if(mysql_num_rows($checknumber) == 1) { echo "<b>Error</b>"; echo "Mobile number in use by another employee!"; } else { $addstaff = mysql_query("INSERT INTO staff (fname, lname, email, no, sia) VALUES('".$fname."', '".$lname."', '".$email."', '".$no."', '".$sia."')"); if($addstaff) { echo "<b>Success!</b>"; echo "Employee added to the database, click <span class=1><a href=stafflist.php>here</a></span> to view employee's"; } else { echo "<b>Error</b>"; echo "<p>There was a problem adding the employee, please try again.</p>"; } } } else { ?> <b>Add an Employee</b> <br><br> Please enter the details below to add an employee to the database. <br><br> <form method="post" action="addstaff.php" name="addstaffform" id="addstaffform"> <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0> <b>Required Information:</b><br><br> <tr><td> <b>First Name:</b> </td><td> <input type="text" name="first" id="first" /> </td></tr><tr><td> <b>Last Name:</b> </td><td> <input type="text" name="last" id="last" /> </td></tr><tr><td> <b>Email Address:</b> </td><td> <input type="text" name="email" id="email" /> </td></tr></table></td><td valign=top> <table border=0> <b>More Information:</b><br><br> <tr><td> <b>SIA License Number:</b> </td><td> <input type="text" name="sia" id="sia"> </td></tr><tr><td> <b>Contact Number:</b> </td><td> <input type="text" name="no" id="no"> </tr></td></td> </table> </td></tr> </table> <input type="submit" name="add" id="add" value="Add Employee" class=btn /> </form> <?php } ?> </div> <?php include ('footer.php'); ?> I don't understand it? Whats wrong with it? Hi, First of all, this is not a mysql error I got the following script which updates a mysql field before redirecting the script to another "page" to get the users information from the database and then sending an email to notify the user that their account has been approved. However, the message isnt sent and the Approval Message Failed message is displayed. Here are both parts of the script although it is the second part which is failing. Code: [Select] case "approval": include_once("data/mysql.php"); $mysqlPassword = (base64_decode($mysqlpword)); $username = $_GET['username']; $db = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die ("Error connecting to database"); mysql_select_db("$dbname", $db) or die ("An error occured when connecting to database"); mysql_query("UPDATE members SET approved = 'yes' WHERE username = '$username'"); mysql_close($db); header("Location: admin.php?cmd=appMailSend&username=$username"); break; Part 2 Code: [Select] case "appMailSend": include_once("data/mysql.php"); include_once("data/server.php"); $username = $_GET['username']; function decode_variable(&$siteName) { $siteName = urldecode($siteName); $siteName = str_replace('%20',' ',$siteName); return $siteName; } decode_variable($siteName); $mysqlPassword = (base64_decode($mysqlpword)); $db = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die ("Error connecting to database"); mysql_select_db("$dbname", $db) or die ("An error occured when connecting to database"); $data = mysql_query("SELECT * FROM members WHERE username='$username'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { $email = $data['email']; $username = $data['username']; $firstname = $data['firstname']; $password = $data['password']; } mysql_close($db); // Send Approval email $bodyApp = file_get_contents('data/approvalMail.php'); $to = "$email"; $subject = "Welcome to $siteName"; $body = "\nDear $firstname;\n$bodyApp\nUsername: $username';\n Password: $password;"; if (mail($to, $subject, $body)) { // Redirect back to manage page header("Location: admin.php?cmd=manage1"); } else { echo "Approval Message Failed"; } break; As always, any help is much appreciated. Paul To give some background, I'm currently working on a private site that allows members access to large document files via a torrent system. Now, this is the PHP code I have: Code: [Select] $id = $_REQUEST['id']; if (!$id) httperr(); $res = mysql_query("SELECT name FROM torrents WHERE id = $id") or sqlerr(__FILE__, __LINE__); $row = mysql_fetch_assoc($res); $fn = "$torrent_dir/$id.torrent"; if (!$row || !is_file($fn) || !is_readable($fn)) httperr(); $fs = filesize($fn); $tor_fname = $row["filename"]; mysql_query("UPDATE torrents SET hits = hits + 1 WHERE id = $id"); require_once "include/benc.php"; // Torrent Encoding Functions $dict = bdec_file($fn, (1024*1024)); $dict['value']['announce']['value'] = "$DEFAULTBASEURL/announce.php?passkey=$CURUSER[passkey]"; $dict['value']['announce']['string'] = strlen($dict['value']['announce']['value']).":".$dict['value']['announce']['value']; $dict['value']['announce']['strlen'] = strlen($dict['value']['announce']['string']); header("Content-Type: application/x-bittorrent"); header("Content-Disposition: attachment; filename=\"" . basename($tor_fname) . "\"" ); print(benc($dict)); This is taken from (and is the majority of) the file download.php. This is called like: download.php?id=?? The above should work, but when I use it, it tries to save the file as download.torrent, even though the $tor_fname variable doesn't contain that value. I'd obviously like to force the filename to be '<filename>.torrent' rather than the same name as the php script with .torrent on the end. Any ideas? Am I doing something stupid, or is there some way of doing this? here is my change password script (This is being done by the admin)
<?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require 'connect.php'; if(isset($_POST['change'])) { $newp = trim($_POST['npass']); $confp = trim($_POST['cpass']); if(empty(trim($newp))) { echo "<h3><center>You did not enter a new password!</center></h3>"; exit(); } if(empty(trim($confp))) { echo "<h3><center>You must confirm the password!</center></h3>"; exit(); } if($confp !== $newp) { echo "Passwords do not match!, try again."; } else { $sql = "UPDATE $db_name SET cpass='$password' WHERE id=' ".$row['id']." '"; echo " ".$row['username']."\s password has been reset! "; } } ?> <html><title> Change password </title><head><style>#form {border-radius: 20px;font-family: sans-serif; margin-top: 60px; padding: 30px;background-color: #aaa;margin-left: auto; margin-right: auto; width: 500px; clear: both;} #form input {width: 100%; clear: both;} #form input:hover {border: 1px solid #ff0000;}</style></head> <body> <div id="form"> <form action='' method='POST'> <h2><b><center>Change Password</center></b></h2><br> <tr> <td><b>New password:</b><input type="password" name="npass" placeholder="Enter new password" /></td><br><br> <td><b>Confirm password:</b><input type="password" name="cpass" placeholder="Confirm password" /></td><br><br> <td><input type="submit" name="change" value="Change!" /></td> </tr> </form> </div><!-- end of form div --> </body> </html>I'm getting Notice: Undefined variable: row in C:\xampp\htdocs\Login\web_dir\changepassword.php on line 30 Notice: Undefined variable: row in C:\xampp\htdocs\Login\web_dir\changepassword.php on line 32And it say's \s password has been reset!It's saying that the variable row is undefined, it's defined in my edit user / select user page <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); session_start(); require 'connect.php'; echo "<title> Edit a user </title>"; $sql = "SELECT id, username FROM $tbl_name ORDER BY username"; $result = $con->query($sql); while ($row = $result->fetch_assoc()) { echo "<div id='l'><tr><td>{$row['username']}</td> | <td><a href='editUser.php?id={$row['id']}'>Edit User</a> |</td> <td><a href='changepassword.php?id={$row['id']}'>Change Password</a> |</td> <td><a href='banUser.php?id={$row['id']}'>Ban User</a></td><br><br> </tr></div>\n"; } ?>Also it doesn't actually UPDATE the password. So the site is using a flash section to control navigation. when I click the button pages are not loaded only the flash here is url: Script to control flash generated url Code: [Select] <?php function fudgePage(){ $url = trim(strtolower(preg_replace('([^[:alnum:]\|\/\:\.\_\-])', '', "http://".$_SERVER['SERVER_NAME'].'/'.$_SERVER['REQUEST_URI']))); $parts = parse_url($url,PHP_URL_PATH); $sections = explode('/',trim($parts,'/')); $section = @ trim(substr(ereg_replace('([^[:alnum:]\-])','',$sections[0]),0,50)); $subsection = @ trim(substr(ereg_replace('([^[:alnum:]\-])','',$sections[1]),0,50)); $pages = array(); $pages[''] = "sections/homeContent.php"; $pages['residential'] = "sections/residentialContent.php"; $pages['residential-virtual-tours'] = "sections/virtualTours.php"; $pages['residential-features'] = "sections/featuresContent.php"; $pages['residential-floorplans'] = "sections/floorPlansContent.php"; $pages['residential-site-key-plan'] = "sections/siteKeyContent.php"; $pages['retail'] = "sections/retailContent.php"; $pages['interest'] = "sections/emailContent.php"; $pages['location'] = "sections/locationContent.php"; $pages['contact'] = "sections/contactContent.php"; $pages['news'] = "sections/newsContent.php"; $pages['icon-gallery'] = "sections/galleryContent.php"; $key = @ (!empty($subsection) && $section != 'interest') ? $section.'-'.$subsection : $section ; $page = @ $pages[$key]; return array('subsection' => $subsection, 'section' => $section, 'page' => $page); } ?> INDEX PAGE Code: [Select] <?php $baseurl = 'http://SomDomain.com/'; $baseinc = dirname(realpath(__FILE__)); include('dirty-hack.php'); $params = fudgePage(); $swf = (!empty($params['section'])) ? $params['section'].'.swf' : 'home.swf' ; $include = (!empty($params['page'])) ? $params['page'] : "sections/homeContent.php" ; ?> <!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> <link rel="stylesheet" href="<?php echo $baseurl ?>css/styles.css" type="text/css" media="all" charset="utf-8" /> <!--[if IE]> <link rel="stylesheet" href="<?php echo $baseurl ?>css/ie-styles.css" type="text/css" media="all" charset="utf-8" /> <![endif]--> <script type="text/javascript" language="javascript" src="<?php echo $baseurl ?>js/prototype.js" charset="utf-8"></script> <script type="text/javascript" language="javascript" src="<?php echo $baseurl ?>js/scriptaculous.js" charset="utf-8"></script> <script type="text/javascript" language="javascript" src="<?php echo $baseurl ?>js/effects.js" charset="utf-8"></script> <script type="text/javascript" language="javascript" src="<?php echo $baseurl ?>js/scripts.js" charset="utf-8"></script> <script type="text/javascript" language="javascript" src="<?php echo $baseurl ?>js/fo.js" charset="utf-8"></script> <style type="text/css"> #slideshow { position: relative; width: 310px; height: 422px; } #slideshow div { position: absolute; left: 0; top: 0; } </style> <base href="<?php echo $baseinc ?>" /> </head> <body> <?php /*<script type="text/javascript" language="javascript" src="<?php echo $baseurl ?>js/slideshow.js" charset="utf-8"></script> <script type="text/javascript">new Slideshow('slideshow', 5000);</script> */ ?> <div id="top"> <div id="click-hack" style="float:left; position:absolute; top:250px; z-index:5; width:150px; height:75px; cursor:pointer;" onclick="window.location='<?php echo $baseurl ?>';"><img src="<?php echo $baseurl ?>images/blank.gif" height="75" width="150"></div> <div id="flash"> <div id="flashObject"> </div> <script type="text/javascript" language="javascript" charset="utf-8"> // <![CDATA[ var fo = new FlashObject("<?php echo $baseurl . $swf ?>", "ICONsite", "782", "325", "7", "#0f0f0f",wmode="transparent"); fo.addParam("menu", "false"); fo.addParam("scale", "exactfit"); fo.addParam("wmode", "transparent"); fo.addParam("quality", "high"); fo.addParam("allowScriptAccess", "sameDomain"); fo.write("flashObject"); // ]]> </script> </div> <iframe src="ticker/index.html" width="100%" height="34" frameborder="0" scrolling="no"></iframe> <div id="container"> <?php include($baseinc. $include); ?> </div> <div id="footer" class="clear"> <div id="footerAddress"> <a href="http://www.somedomain.com/" target="_blank"> <img src="images/footer.jpg" alt="" style="overflow: hidden;" /> </a> </div> </div> <div id="footer-nav" class="clear"> <!--img src="images/icon-sm.gif" alt="" /--> <br /> <ul> <li class="none"><a href="<?php echo $baseurl ?>">Home</a></li> <li class="none"><a href="<?php echo $baseurl ?>residential">Residential</a></li> <li class="none"><a href="<?php echo $baseurl ?>residential/virtual-tours">Virtual Tours</a></li> <li class="none"><a href="<?php echo $baseurl ?>residential/features">Features</a></li> <li class="none"><a href="<?php echo $baseurl ?>residential/floorplans">Floorplans</a></li> <li class="none"><a href="<?php echo $baseurl ?>residential/site-key-plan">Site Key Plan</a></li> <li class="none"><a href="<?php echo $baseurl ?>retail">Retail</a></li> <li class="none"><a href="<?php echo $baseurl ?>interest">Available Units</a></li> <li class="none"><a href="<?php echo $baseurl ?>location">Location</a></li> <li class="none"><a href="<?php echo $baseurl ?>contact">Contact</a></li> <li class="none"><a href="<?php echo $baseurl ?>news">News</a></li> <li class="none"><a href="<?php echo $baseurl ?>icon-gallery">Gallery</a></li> <li class="none"><a href="<?php echo $baseurl ?>privacypolicy.php" onclick="oWin('privacypolicy.php', '', '512', '380'); return false;">Privacy Policy</a></li> </ul> <br /> <br /> </div> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-1188345-10"); pageTracker._initData(); pageTracker._trackPageview(); </script> </body> </html> Hi everyone, my contact us form and script isn't working how it should. On send the data is not sent to the db, a () is the ONLY thing shown in the browser too, can somebody help make this work? Heres the form: Code: [Select] <form method="get" action="contact-send.php"> Name:<br /> <input type="text" name="name" id="name" size="30" /><br /> Email:<br /> <input type="email" name="email" id="email" size="30" /><br /> Your Question:<br /> <textarea name="question" id="question" rows="10" cols="50"></textarea><br /> <input type="submit" name="submit" value="send" /> </form And the script to process: Code: [Select] <?PHP session_start(); include ('php only scripts/db.php'); if ($db_found) { $SQL = "INSERT INTO 'contact_us' (name, email, question) VALUES ('" .$name. "', '" .$email. "', '" .$question. "')"; $result = mysql_query($query) or die(mysql_error()); header( 'Location: http://www.removalspace.com/contactconf.php' ); } ?> Iv'e messed with it and had database NOT found before but since then, messed some more and before i go in circles i need some help :| Thanks in advance for any help! Hi friends,
I have this script for countdown Timer, and when i open my site the timer show Nan, can you help me please
/* http://keith-wood.name/countdown.html Countdown for jQuery v2.0.0. Written by Keith Wood (kbwood{at}iinet.com.au) January 2008. Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license. Please attribute the author if you use it. */ (function($) { // Hide scope, no $ conflict var pluginName = 'countdown'; var Y = 0; // Years var O = 1; // Months var W = 2; // Weeks var D = 3; // Days var H = 4; // Hours var M = 5; // Minutes var S = 6; // Seconds /** Create the countdown plugin. <p>Sets an element to show the time remaining until a given instant.</p> <p>Expects HTML like:</p> <pre><div></div></pre> <p>Provide inline configuration like:</p> <pre><div data-countdown="name: 'value'"></div></pre> @module Countdown @augments JQPlugin @example $(selector).countdown({until: +300}) */ $.JQPlugin.createPlugin({ /** The name of the plugin. */ name: pluginName, /** Countdown expiry callback. Triggered when the countdown expires. @callback expiryCallback */ /** Countdown server synchronisation callback. Triggered when the countdown is initialised. @callback serverSyncCallback @return {Date} The current date/time on the server as expressed in the local timezone. */ /** Countdown tick callback. Triggered on every <code>tickInterval</code> ticks of the countdown. @callback tickCallback @param periods {number[]} The breakdown by period (years, months, weeks, days, hours, minutes, seconds) of the time remaining/passed. */ /** Countdown which labels callback. Triggered when the countdown is being display to determine which set of labels (<code>labels</code>, <code>labels1</code>, ...) are to be used for the current period value. @callback whichLabelsCallback @param num {number} The current period value. @return {number} The suffix for the label set to use. */ /** Default settings for the plugin. @property until {Date|number|string} The date/time to count down to, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @example until: new Date(2013, 12-1, 25, 13, 30) until: +300 until: '+1O -2D' @property [since] {Date|number|string} The date/time to count up from, or number of seconds offset from now, or string for unit offset(s): 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @example since: new Date(2013, 1-1, 1) since: -300 since: '-1O +2D' @property [timezone=null] {number} The timezone (hours or minutes from GMT) for the target times, or null for client local timezone. @example timezone: +10 timezone: -60 @property [serverSync=null] {serverSyncCallback} A function to retrieve the current server time for synchronisation. @property [format='dHMS'] {string} The format for display - upper case for always, lower case only if non-zero, 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @property [layout=''] {string} Build your own layout for the countdown. @example layout: '{d<}{dn} {dl}{d>} {hnn}:{mnn}:{snn}' @property [compact=false] {boolean} True to display in a compact format, false for an expanded one. @property [padZeroes=false] {boolean} True to add leading zeroes @property [significant=0] {number} The number of periods with non-zero values to show, zero for all. @property [description=''] {string} The description displayed for the countdown. @property [expiryUrl=''] {string} A URL to load upon expiry, replacing the current page. @property [expiryText=''] {string} Text to display upon expiry, replacing the countdown. This may be HTML. @property [alwaysExpire=false] {boolean} True to trigger <code>onExpiry</code> even if target time has passed. @property [onExpiry=null] {expiryCallback} Callback when the countdown expires - receives no parameters and <code>this</code> is the containing division. @example onExpiry: function() { ... } @property [onTick=null] {tickCallback} Callback when the countdown is updated - receives <code>number[7]</code> being the breakdown by period (years, months, weeks, days, hours, minutes, seconds - based on <code>format</code>) and <code>this</code> is the containing division. @example onTick: function(periods) { var secs = $.countdown.periodsToSeconds(periods); if (secs < 300) { // Last five minutes ... } } @property [tickInterval=1] {number} The interval (seconds) between <code>onTick</code> callbacks. */ defaultOptions: { until: null, since: null, timezone: null, serverSync: null, format: 'dHMS', layout: '', compact: false, padZeroes: false, significant: 0, description: '', expiryUrl: '', expiryText: '', alwaysExpi false, onExpiry: null, onTick: null, tickInterval: 1 }, /** Localisations for the plugin. Entries are objects indexed by the language code ('' being the default US/English). Each object has the following attributes. @property [labels=['Years','Months','Weeks','Days','Hours','Minutes','Seconds']] {string[]} The display texts for the counter periods. @property [labels1=['Year','Month','Week','Day','Hour','Minute','Second']] {string[]} The display texts for the counter periods if they have a value of 1. Add other <code>labels<em>n</em></code> attributes as necessary to cater for other numeric idiosyncrasies of the localisation. @property [compactLabels=['y','m','w','d']] {string[]} The compact texts for the counter periods. @property [whichLabels=null] {whichLabelsCallback} A function to determine which <code>labels<em>n</em></code> to use. @example whichLabels: function(num) { return (num > 1 ? 0 : 1); } @property [digits=['0','1',...,'9']] {number[]} The digits to display (0-9). @property [timeSeparator=':'] {string} Separator for time periods in the compact layout. @property [isRTL=false] {boolean} True for right-to-left languages, false for left-to-right. */ regionalOptions: { // Available regional settings, indexed by language/country code '': { // Default regional settings - English/US labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'], labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'], compactLabels: ['y', 'm', 'w', 'd'], whichLabels: null, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], timeSeparator: ':', isRTL: false } }, /** Names of getter methods - those that can't be chained. */ _getters: ['getTimes'], /* Class name for the right-to-left marker. */ _rtlClass: pluginName + '-rtl', /* Class name for the countdown section marker. */ _sectionClass: pluginName + '-section', /* Class name for the period amount marker. */ _amountClass: pluginName + '-amount', /* Class name for the period name marker. */ _periodClass: pluginName + '-period', /* Class name for the countdown row marker. */ _rowClass: pluginName + '-row', /* Class name for the holding countdown marker. */ _holdingClass: pluginName + '-holding', /* Class name for the showing countdown marker. */ _showClass: pluginName + '-show', /* Class name for the description marker. */ _descrClass: pluginName + '-descr', /* List of currently active countdown elements. */ _timerElems: [], /** Additional setup for the countdown. Apply default localisations. Create the timer. */ _init: function() { var self = this; this._super(); this._serverSyncs = []; var now = (typeof Date.now == 'function' ? Date.now : function() { return new Date().getTime(); }); var perfAvail = (window.performance && typeof window.performance.now == 'function'); // Shared timer for all countdowns function timerCallBack(timestamp) { var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer (perfAvail ? (performance.now() + performance.timing.navigationStart) : now()) : // Integer milliseconds since unix epoch timestamp || now()); if (drawStart - animationStartTime >= 1000) { self._updateElems(); animationStartTime = drawStart; } requestAnimationFrame(timerCallBack); } var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null; // This is when we expect a fall-back to setInterval as it's much more fluid var animationStartTime = 0; if (!requestAnimationFrame || $.noRequestAnimationFrame) { $.noRequestAnimationFrame = null; setInterval(function() { self._updateElems(); }, 980); // Fall back to good old setInterval } else { animationStartTime = window.animationStartTime || window.webkitAnimationStartTime || window.mozAnimationStartTime || window.oAnimationStartTime || window.msAnimationStartTime || now(); requestAnimationFrame(timerCallBack); } }, /** Convert a date/time to UTC. @param tz {number} The hour or minute offset from GMT, e.g. +9, -360. @param year {Date|number} the date/time in that timezone or the year in that timezone. @param [month] {number} The month (0 - 11) (omit if <code>year</code> is a <code>Date</code>). @param [day] {number} The day (omit if <code>year</code> is a <code>Date</code>). @param [hours] {number} The hour (omit if <code>year</code> is a <code>Date</code>). @param [mins] {number} The minute (omit if <code>year</code> is a <code>Date</code>). @param [secs] {number} The second (omit if <code>year</code> is a <code>Date</code>). @param [ms] {number} The millisecond (omit if <code>year</code> is a <code>Date</code>). @return {Date} The equivalent UTC date/time. @example $.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0) $.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0)) */ UTCDate: function(tz, year, month, day, hours, mins, secs, ms) { if (typeof year == 'object' && year.constructor == Date) { ms = year.getMilliseconds(); secs = year.getSeconds(); mins = year.getMinutes(); hours = year.getHours(); day = year.getDate(); month = year.getMonth(); year = year.getFullYear(); } var d = new Date(); d.setUTCFullYear(year); d.setUTCDate(1); d.setUTCMonth(month || 0); d.setUTCDate(day || 1); d.setUTCHours(hours || 0); d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz)); d.setUTCSeconds(secs || 0); d.setUTCMilliseconds(ms || 0); return d; }, /** Convert a set of periods into seconds. Averaged for months and years. @param periods {number[]} The periods per year/month/week/day/hour/minute/second. @return {number} The corresponding number of seconds. @example var secs = $.countdown.periodsToSeconds(periods) */ periodsToSeconds: function(periods) { return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 + periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6]; }, _instSettings: function(elem, options) { return {_periods: [0, 0, 0, 0, 0, 0, 0]}; }, /** Add an element to the list of active ones. @private @param elem {Element} The countdown element. */ _addElem: function(elem) { if (!this._hasElem(elem)) { this._timerElems.push(elem); } }, /** See if an element is in the list of active ones. @private @param elem {Element} The countdown element. @return {boolean} True if present, false if not. */ _hasElem: function(elem) { return ($.inArray(elem, this._timerElems) > -1); }, /** Remove an element from the list of active ones. @private @param elem {Element} The countdown element. */ _removeElem: function(elem) { this._timerElems = $.map(this._timerElems, function(value) { return (value == elem ? null : value); }); // delete entry }, /** Update each active timer element. @private */ _updateElems: function() { for (var i = this._timerElems.length - 1; i >= 0; i--) { this._updateCountdown(this._timerElems[i]); } }, _optionsChanged: function(elem, inst, options) { if (options.layout) { options.layout = options.layout.replace(/</g, '<').replace(/>/g, '>'); } this._resetExtraLabels(inst.options, options); var timezoneChanged = (inst.options.timezone != options.timezone); $.extend(inst.options, options); this._adjustSettings(elem, inst, options.until != null || options.since != null || timezoneChanged); var now = new Date(); if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) { this._addElem(elem[0]); } this._updateCountdown(elem, inst); }, /** Redisplay the countdown with an updated display. @private @param elem {Element|jQuery} The containing division. @param inst {object} The current settings for this instance. */ _updateCountdown: function(elem, inst) { elem = elem.jquery ? elem : $(elem); inst = inst || elem.data(this.name); if (!inst) { return; } elem.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL); if ($.isFunction(inst.options.onTick)) { var periods = inst._hold != 'lap' ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()); if (inst.options.tickInterval == 1 || this.periodsToSeconds(periods) % inst.options.tickInterval == 0) { inst.options.onTick.apply(elem[0], [periods]); } } var expired = inst._hold != 'pause' && (inst._since ? inst._now.getTime() < inst._since.getTime() : inst._now.getTime() >= inst._until.getTime()); if (expired && !inst._expiring) { inst._expiring = true; if (this._hasElem(elem[0]) || inst.options.alwaysExpire) { this._removeElem(elem[0]); if ($.isFunction(inst.options.onExpiry)) { inst.options.onExpiry.apply(elem[0], []); } if (inst.options.expiryText) { var layout = inst.options.layout; inst.options.layout = inst.options.expiryText; this._updateCountdown(elem[0], inst); inst.options.layout = layout; } if (inst.options.expiryUrl) { window.location = inst.options.expiryUrl; } } inst._expiring = false; } else if (inst._hold == 'pause') { this._removeElem(elem[0]); } }, /** Reset any extra labelsn and compactLabelsn entries if changing labels. @private @param base {object} The options to be updated. @param options {object} The new option values. */ _resetExtraLabels: function(base, options) { var changingLabels = false; for (var n in options) { if (n != 'whichLabels' && n.match(/[Ll]abels/)) { changingLabels = true; break; } } if (changingLabels) { for (var n in base) { // Remove custom numbered labels if (n.match(/[Ll]abels[02-9]|compactLabels1/)) { base[n] = null; } } } }, /** Calculate internal settings for an instance. @private @param elem {jQuery} The containing division. @param inst {object} The current settings for this instance. @param recalc {boolean} True if until or since are set. */ _adjustSettings: function(elem, inst, recalc) { var now; var serverOffset = 0; var serverEntry = null; for (var i = 0; i < this._serverSyncs.length; i++) { if (this._serverSyncs[i][0] == inst.options.serverSync) { serverEntry = this._serverSyncs[i][1]; break; } } if (serverEntry != null) { serverOffset = (inst.options.serverSync ? serverEntry : 0); now = new Date(); } else { var serverResult = ($.isFunction(inst.options.serverSync) ? inst.options.serverSync.apply(elem[0], []) : null); now = new Date(); serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0); this._serverSyncs.push([inst.options.serverSync, serverOffset]); } var timezone = inst.options.timezone; timezone = (timezone == null ? -now.getTimezoneOffset() : timezone); if (recalc || (!recalc && inst._until == null && inst._since == null)) { inst._since = inst.options.since; if (inst._since != null) { inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null)); if (inst._since && serverOffset) { inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset); } } inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now)); if (serverOffset) { inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset); } } inst._show = this._determineShow(inst); }, /** Remove the countdown widget from a div. @param elem {jQuery} The containing division. @param inst {object} The current instance object. */ _preDestroy: function(elem, inst) { this._removeElem(elem[0]); elem.empty(); }, /** Pause a countdown widget at the current time. Stop it running but remember and display the current time. @param elem {Element} The containing division. @example $(selector).countdown('pause') */ pause: function(elem) { this._hold(elem, 'pause'); }, /** Pause a countdown widget at the current time. Stop the display but keep the countdown running. @param elem {Element} The containing division. @example $(selector).countdown('lap') */ lap: function(elem) { this._hold(elem, 'lap'); }, /** Resume a paused countdown widget. @param elem {Element} The containing division. @example $(selector).countdown('resume') */ resume: function(elem) { this._hold(elem, null); }, /** Toggle a paused countdown widget. @param elem {Element} The containing division. @example $(selector).countdown('toggle') */ toggle: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'pause' : 'resume'](elem); }, /** Toggle a lapped countdown widget. @param elem {Element} The containing division. @example $(selector).countdown('toggleLap') */ toggleLap: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'lap' : 'resume'](elem); }, /** Pause or resume a countdown widget. @private @param elem {Element} The containing division. @param hold {string} The new hold setting. */ _hold: function(elem, hold) { var inst = $.data(elem, this.name); if (inst) { if (inst._hold == 'pause' && !hold) { inst._periods = inst._savePeriods; var sign = (inst._since ? '-' : '+'); inst[inst._since ? '_since' : '_until'] = this._determineTime(sign + inst._periods[0] + 'y' + sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' + sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' + sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's'); this._addElem(elem); } inst._hold = hold; inst._savePeriods = (hold == 'pause' ? inst._periods : null); $.data(elem, this.name, inst); this._updateCountdown(elem, inst); } }, /** Return the current time periods. @param elem {Element} The containing division. @return {number[]} The current periods for the countdown. @example var periods = $(selector).countdown('getTimes') */ getTimes: function(elem) { var inst = $.data(elem, this.name); return (!inst ? null : (inst._hold == 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())))); }, /** A time may be specified as an exact value or a relative one. @private @param setting {string|number|Date} The date/time value as a relative or absolute value. @param defaultTime {Date} The date/time to use if no other is supplied. @return {Date} The corresponding date/time. */ _determineTime: function(setting, defaultTime) { var self = this; var offsetNumeric = function(offset) { // e.g. +300, -2 var time = new Date(); time.setTime(time.getTime() + offset * 1000); return time; }; var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m' offset = offset.toLowerCase(); var time = new Date(); var year = time.getFullYear(); var month = time.getMonth(); var day = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g; var matches = pattern.exec(offset); while (matches) { switch (matches[2] || 's') { case 's': second += parseInt(matches[1], 10); break; case 'm': minute += parseInt(matches[1], 10); break; case 'h': hour += parseInt(matches[1], 10); break; case 'd': day += parseInt(matches[1], 10); break; case 'w': day += parseInt(matches[1], 10) * 7; break; case 'o': month += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; case 'y': year += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; } matches = pattern.exec(offset); } return new Date(year, month, day, hour, minute, second, 0); }; var time = (setting == null ? defaultTime : (typeof setting == 'string' ? offsetString(setting) : (typeof setting == 'number' ? offsetNumeric(setting) : setting))); if (time) time.setMilliseconds(0); return time; }, /** Determine the number of days in a month. @private @param year {number} The year. @param month {number} The month. @return {number} The days in that month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /** Default implementation to determine which set of labels should be used for an amount. Use the <code>labels</code> attribute with the same numeric suffix (if it exists). @private @param num {number} The amount to be displayed. @return {number} The set of labels to be used for this amount. */ _normalLabels: function(num) { return num; }, /** Generate the HTML to display the countdown widget. @private @param inst {object} The current settings for this instance. @return {string} The new HTML for the countdown display. */ _generateHTML: function(inst) { var self = this; // Determine what to show inst._periods = (inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())); // Show all 'asNeeded' after first non-zero value var shownNonZero = false; var showCount = 0; var sigCount = inst.options.significant; var show = $.extend({}, inst._show); for (var period = Y; period <= S; period++) { shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0); show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]); showCount += (show[period] ? 1 : 0); sigCount -= (inst._periods[period] > 0 ? 1 : 0); } var showSignificant = [false, false, false, false, false, false, false]; for (var period = S; period >= Y; period--) { // Determine significant periods if (inst._show[period]) { if (inst._periods[period]) { showSignificant[period] = true; } else { showSignificant[period] = sigCount > 0; sigCount--; } } } var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels); var whichLabels = inst.options.whichLabels || this._normalLabels; var showCompact = function(period) { var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])]; return (show[period] ? self._translateDigits(inst, inst._periods[period]) + (labelsNum ? labelsNum[period] : labels[period]) + ' ' : ''); }; var minDigits = (inst.options.padZeroes ? 2 : 1); var showFull = function(period) { var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])]; return ((!inst.options.significant && show[period]) || (inst.options.significant && showSignificant[period]) ? '<span class="' + self._sectionClass + '">' + '<span class="' + self._amountClass + '">' + self._minDigits(inst, inst._periods[period], minDigits) + '</span>' + '<span class="' + self._periodClass + '">' + (labelsNum ? labelsNum[period] : labels[period]) + '</span></span>' : ''); }; return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout, inst.options.compact, inst.options.significant, showSignificant) : ((inst.options.compact ? // Compact version '<span class="' + this._rowClass + ' ' + this._amountClass + (inst._hold ? ' ' + this._holdingClass : '') + '">' + showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) + (show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') + (show[M] ? (show[H] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[M], 2) : '') + (show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[S], 2) : '') : // Full version '<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) + (inst._hold ? ' ' + this._holdingClass : '') + '">' + showFull(Y) + showFull(O) + showFull(W) + showFull(D) + showFull(H) + showFull(M) + showFull(S)) + '</span>' + (inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' + inst.options.description + '</span>' : ''))); }, /** Construct a custom layout. @private @param inst {object} The current settings for this instance. @param show {boolean[]} Flags indicating which periods are requested. @param layout {string} The customised layout. @param compact {boolean} True if using compact labels. @param significant {number} The number of periods with values to show, zero for all. @param showSignificant {boolean[]} Other periods to show for significance. @return {string} The custom HTML. */ _buildLayout: function(inst, show, layout, compact, significant, showSignificant) { var labels = inst.options[compact ? 'compactLabels' : 'labels']; var whichLabels = inst.options.whichLabels || this._normalLabels; var labelFor = function(index) { return (inst.options[(compact ? 'compactLabels' : 'labels') + whichLabels(inst._periods[index])] || labels)[index]; }; var digit = function(value, position) { return inst.options.digits[Math.floor(value / position) % 10]; }; var subs = {desc: inst.options.description, sep: inst.options.timeSeparator, yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1), ynn: this._minDigits(inst, inst._periods[Y], 2), ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1), y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100), y1000: digit(inst._periods[Y], 1000), ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1), onn: this._minDigits(inst, inst._periods[O], 2), onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1), o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100), o1000: digit(inst._periods[O], 1000), wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1), wnn: this._minDigits(inst, inst._periods[W], 2), wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1), w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100), w1000: digit(inst._periods[W], 1000), dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1), dnn: this._minDigits(inst, inst._periods[D], 2), dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1), d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100), d1000: digit(inst._periods[D], 1000), hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1), hnn: this._minDigits(inst, inst._periods[H], 2), hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1), h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100), h1000: digit(inst._periods[H], 1000), ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1), mnn: this._minDigits(inst, inst._periods[M], 2), mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1), m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100), m1000: digit(inst._periods[M], 1000), sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1), snn: this._minDigits(inst, inst._periods[S], 2), snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1), s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100), s1000: digit(inst._periods[S], 1000)}; var html = layout; // Replace period containers: {p<}...{p>} for (var i = Y; i <= S; i++) { var period = 'yowdhms'.charAt(i); var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g'); html = html.replace(re, ((!significant && show[i]) || (significant && showSignificant[i]) ? '$1' : '')); } // Replace period values: {pn} $.each(subs, function(n, v) { var re = new RegExp('\\{' + n + '\\}', 'g'); html = html.replace(re, v); }); return html; }, /** Ensure a numeric value has at least n digits for display. @private @param inst {object} The current settings for this instance. @param value {number} The value to display. @param len {number} The minimum length. @return {string} The display text. */ _minDigits: function(inst, value, len) { value = '' + value; if (value.length >= len) { return this._translateDigits(inst, value); } value = '0000000000' + value; return this._translateDigits(inst, value.substr(value.length - len)); }, /** Translate digits into other representations. @private @param inst {object} The current settings for this instance. @param value {string} The text to translate. @return {string} The translated text. */ _translateDigits: function(inst, value) { return ('' + value).replace(/[0-9]/g, function(digit) { return inst.options.digits[digit]; }); }, /** Translate the format into flags for each period. @private @param inst {object} The current settings for this instance. @return {string[]} Flags indicating which periods are requested (?) or required (!) by year, month, week, day, hour, minute, second. */ _determineShow: function(inst) { var format = inst.options.format; var show = []; show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null)); show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null)); show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null)); show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null)); show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null)); show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null)); show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null)); return show; }, /** Calculate the requested periods between now and the target time. @private @param inst {object} The current settings for this instance. @param show {string[]} Flags indicating which periods are requested/required. @param significant {number} The number of periods with values to show, zero for all. @param now {Date} The current date and time. @return {number[]} The current time periods (always positive) by year, month, week, day, hour, minute, second. */ _calculatePeriods: function(inst, show, significant, now) { // Find endpoints inst._now = now; inst._now.setMilliseconds(0); var until = new Date(inst._now.getTime()); if (inst._since) { if (now.getTime() < inst._since.getTime()) { inst._now = now = until; } else { now = inst._since; } } else { until.setTime(inst._until.getTime()); if (now.getTime() > inst._until.getTime()) { inst._now = now = until; } } // Calculate differences by period var periods = [0, 0, 0, 0, 0, 0, 0]; if (show[Y] || show[O]) { // Treat end of months as the same var lastNow = this._getDaysInMonth(now.getFullYear(), now.getMonth()); var lastUntil = this._getDaysInMonth(until.getFullYear(), until.getMonth()); var sameDay = (until.getDate() == now.getDate() || (until.getDate() >= Math.min(lastNow, lastUntil) && now.getDate() >= Math.min(lastNow, lastUntil))); var getSecs = function(date) { return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds(); }; var months = Math.max(0, (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() + ((until.getDate() < now.getDate() && !sameDay) || (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0)); periods[Y] = (show[Y] ? Math.floor(months / 12) : 0); periods[O] = (show[O] ? months - periods[Y] * 12 : 0); // Adjust for months difference and end of month if necessary now = new Date(now.getTime()); var wasLastDay = (now.getDate() == lastNow); var lastDay = this._getDaysInMonth(now.getFullYear() + periods[Y], now.getMonth() + periods[O]); if (now.getDate() > lastDay) { now.setDate(lastDay); } now.setFullYear(now.getFullYear() + periods[Y]); now.setMonth(now.getMonth() + periods[O]); if (wasLastDay) { now.setDate(lastDay); } } var diff = Math.floor((until.getTime() - now.getTime()) / 1000); var extractPeriod = function(period, numSecs) { periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0); diff -= periods[period] * numSecs; }; extractPeriod(W, 604800); extractPeriod(D, 86400); extractPeriod(H, 3600); extractPeriod(M, 60); extractPeriod(S, 1); if (diff > 0 && !inst._since) { // Round up if left overs var multiplier = [1, 12, 4.3482, 7, 24, 60, 60]; var lastShown = S; var max = 1; for (var period = S; period >= Y; period--) { if (show[period]) { if (periods[lastShown] >= max) { periods[lastShown] = 0; diff = 1; } if (diff > 0) { periods[period]++; diff = 0; lastShown = period; max = 1; } } max *= multiplier[period]; } } if (significant) { // Zero out insignificant periods for (var period = Y; period <= S; period++) { if (significant && periods[period]) { significant--; } else if (!significant) { periods[period] = 0; } } } return periods; } }); })(jQuery); Code: [Select] <?php session_start(); require_once("connect.php"); ?> <html> <body> Thanks for buying!<br> Receipt:<br> Amount:<?php echo ($_POST["amount"]);?> <br>Type:<?php echo $_POST["type"];?> <br>Cost:<?php if($_POST["type"]=="pikemen"){ $cost = 20 * $_POST["amount"]; $price = $_SESSION["resources"] - $cost; $name = $_SESSION["username"]; $gained = $_POST["amount"] + $_SESSION["pikemen"]; mysql_query("UPDATE SET pikemen = '$gained' WHERE username = '$name'"); } mysql_query("UPDATE SET resources = '$price' WHERE username = '$name'"); ?> </body> </html> The script is supposed to use some information taken from an input box on the previous page to buy items from the shop, but its not working (it doesnt give errors, just doesnt change the amount of soldiers or resources... |