Jump to content

hellonoko

Members
  • Posts

    213
  • Joined

  • Last visited

Everything posted by hellonoko

  1. So the double quotes within single quotes is wrong and i should concatenate instead?
  2. My below code uses a bit of Flash to create a mini mp3 player button for each mp3 in a directory. As it stands there are 3 test files in the directory but for some reason only the first flash player button is displayed and not the name of the file. So for some reason the loop is failing after the embedded flash. Any ideas? <?php $arr = array(); foreach (glob("*.*") as $filename) { $arr[$filename] = filemtime($filename); } arsort($arr); echo "<br>"; foreach($arr as $key => $value) { if ( $key !== "filelist3.php") { echo '<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key" width="17" height="17">'; echo '<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key"/>'; echo '<img src="noflash.gif" width="17" height="17" alt="" />'; echo "$key<br>"; } } ?>
  3. No luck. When I used your script directly with www.site.com It showed 3 broken flash links and 3 $key's. That is how many files are in the folder. But when I put the correct site in it only display the first button.
  4. I have a simple script that reads through a directory of files (mp3s) and displays the files. The script also uses the XSPF player to show a small Flash mp3 player for each file so that the mp3 can be previewed. However when I run the script only the first song button and not the song name will show up. I have a feeling it is something to do with the quotes of the embedded flash but am not sure. <?php $arr = array(); foreach (glob("*.*") as $filename) { $arr[$filename] = filemtime($filename); } arsort($arr); echo "<br>"; foreach($arr as $key => $value) { if ( $key !== "filelist3.php") { echo "<object type="application/x-shockwave-flash" data="http://www.site.com/button/musicplayer.swf?&song_url=http://www.site.com/REPOSITORY/$key" width="17" height="17">"; echo "<param name="movie" value="http://www.site.com/button/musicplayer.swf?&song_url=http://www.site.com/REPOSITORY/$key"/>"; echo "<img src="noflash.gif" width="17" height="17" alt="" />"; echo " $key<br>"; } } ?> Any ideas? Thanks for your help, ian
  5. Was able to get your code to do what I want: Thanks. <?php $arr = array(); foreach (glob("*.*") as $filename) { $arr[$filename] = filemtime($filename); //echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>"; } /// //asort($arr); //echo "<br>"; //foreach($arr as $key => $value) //{ // echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>"; //} /// arsort($arr); echo "<br>"; foreach($arr as $key => $value) { echo "$key<br>"; } ?>
  6. No errors with GLOB just no results. Your script seems to work. How would I modify this to list the files by date?
  7. Brian. Those scripts worked but the second one showed everything in all directories. But neither do any kind of sorting by date? I know how to display a list of files I just don't know how to sort it by date.
  8. I tired some scripts with glob in them but they just didn't do anything. I was probably using them wrong. Could you show me a functional example?
  9. This is as far as I have been able to get with it. $path = "REPOSITORY"; $narray=array(); $dir_handle = @opendir($path) or die("Unable to open $path"); echo "Directory Listing of $path<br/>"; $i=0; while($file = readdir($dir_handle)) { if(is_dir($file)) { continue; } else if($file != '.' && $file != '..') { //echo "<a href='$path/$file'>$file</a><br/>"; $narray[$i]=$file; $i++; } } rsort($narray); for($i=0; $i<sizeof($narray); $i++) { echo "<a href=".chr(34).$path.$narray[$i].chr(34).">".$narray[$i]."</a><br/>"; } //closing the directory closedir($dir_handle);
  10. I am trying to create a script that displays files that have been uploaded to a directory in order from newest to oldest files. So by date modified or date created. I have found a few scripts online but haven't been able to get any of them to work properly. If anyone could show me how its done or point me to a good script it would be much appreciated. Thanks, ian
  11. I am adding a countdown timer to my todo list that grabs the due date of a todo item from my DB and then creates a timer that counts down based on the current date. The timer code seems to work fine. However when I add it to my output code for my todo list it causes the list to fall into an infinite loop putting out table rows. After outputting the first todo item and timer correctly. Does anyone have any idea why this is happening? The timer is include "timer/timer.php"; on line 131 of the todo code and current commented out. Thanks for your time. Timer Code: <?php //$date = $HTTP_GET_VARS[date]; //$hours = $HTTP_GET_VARS[hours]; //$minutes = $HTTP_GET_VARS[minutes]; //get date from DB include "../dbconnect.php"; //SELECT DATE_FORMAT(myDateField, '%d-%m-%Y') FROM myTable //gets the idea background color from DB //$query = "SELECT DATE_FORMAT(duedate, '%d-%m-%Y') FROM ideas WHERE id='18'"; $query = "SELECT duedate FROM ideas WHERE id = '18'"; //$row['id']"; $result = mysql_query($query); $rows = mysql_fetch_array($result); $duedate = $rows[0]; //echo $duedate; //echo "<br>"; $due_date = date('F j Y H:i:s',strtotime($duedate)); //echo "<br>"; //echo $due_date; //2007-12-28 14:59:59 //$due_date = $date." ".$hours.":".$minutes.":00"; //fake $due_date for testing $due_date = "January 1 2008 00:00:00"; $bg_color = "#FF0000"; ?> <!--<!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>--> <style style="text/css"> .custom { color:#FFFFFF; font: bold 20px Arial, Helvetica, sans-serif; background-color:<?php echo $bg_color;?>; } .lcdstyle{ /*Example CSS to create LCD countdown look*/ background-color:black; color:yellow; font: bold 18px MS Sans Serif; padding: 3px; } .lcdstyle sup{ /*Example CSS to create LCD countdown look*/ font-size: 80% } </style> <script type="text/javascript"> /*********************************************** * Dynamic Countdown script- © Dynamic Drive (http://www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ function cdtime(container, targetdate){ if (!document.getElementById || !document.getElementById(container)) return this.container=document.getElementById(container) this.currentTime=new Date() this.targetdate=new Date(targetdate) this.timesup=false this.updateTime() } cdtime.prototype.updateTime=function(){ var thisobj=this this.currentTime.setSeconds(this.currentTime.getSeconds()+1) setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second } cdtime.prototype.displaycountdown=function(baseunit, functionref){ this.baseunit=baseunit this.formatresults=functionref this.showresults() } cdtime.prototype.showresults=function(){ var thisobj=this var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds if (timediff<0){ //if time is up this.timesup=true this.container.innerHTML=this.formatresults() return } var oneMinute=60 //minute unit in seconds var oneHour=60*60 //hour unit in seconds var oneDay=60*60*24 //day unit in seconds var dayfield=Math.floor(timediff/oneDay) var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour) var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute) var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute)) if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level hourfield=dayfield*24+hourfield dayfield="n/a" } else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level minutefield=dayfield*24*60+hourfield*60+minutefield dayfield=hourfield="n/a" } else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level var secondfield=timediff dayfield=hourfield=minutefield="n/a" } this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield) setTimeout(function(){thisobj.showresults()}, 1000) //update results every second } /////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW////////////////////////////// //Create your own custom format function to pass into cdtime.displaycountdown() //Use arguments[0] to access "Days" left //Use arguments[1] to access "Hours" left //Use arguments[2] to access "Minutes" left //Use arguments[3] to access "Seconds" left //The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown() //For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a" //For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc function formatresults(){ if (this.timesup==false){//if target date/time not yet met var displaystring="<span class='custom'>"+arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds</span>" } else{ //else if target date/time met var displaystring="Future date is here!" } return displaystring } </script> <!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Count Down!</title> </head> <body>--> <div id="countdowncontainer"></div> <!-- <div id="countdowncontainer2"></div> --> <script type="text/javascript"> var futuredate=new cdtime("countdowncontainer", "<?php echo $due_date;?>") futuredate.displaycountdown("days", formatresults) <!-- --> </script> <!--</body> </html>--> TODO code: <link rel="shortcut icon" href="images/favicon.ico" > <?php error_reporting(E_All); session_start(); session_register('sort'); if ($_session['sort'] == NULL) { $_session['sort'] = $HTTP_GET_VARS[sort]; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Idea Box</title> <style type="text/css"> <!-- td,th { font-size: 10px; font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; } body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; } a:link { color: #FFFFFF; } a:visited { color: #FFFFFF; } a:hover { color: #666666; } a:active { color: #FFFFFF; } .menu_text {color: #000000} --> </style> </head> <?php include 'dbconnect.php'; include 'menu.php'; if ( $_session['sort'] == NULL) { $_session['sort'] = "title_ascending"; } if ( $_session['sort'] == "title_ascending" ) { $query = "SELECT * FROM ideas ORDER BY rank ASC"; } else if ( $_session['sort'] = "title_descending") { $query = "SELECT * FROM ideas ORDER BY rank DESC"; } //echo $_session['sort']; $result = mysql_query($query); $rows = mysql_num_rows($result); echo "<table width='100%' border='0' cellspacing='1'>"; for ($i=0; $i <$rows; $i++) { $row = mysql_fetch_array($result); $num_rows = mysql_num_rows($result); echo "<tr>"; /// changes the state of viewing childen IF the idea has children if ( $row[haschildren] == TRUE) { if ( $row[state] == FALSE) { echo "<form action='state.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='state' type='hidden' value='open' />"; echo "<td width='16' align='center' valign='middle' bgcolor='#ffffff'><input type='image' src='images/right.png' alt='Open'></td>"; echo "</form"; } if ( $row[state] == TRUE) { echo "<form action='state.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='state' type='hidden' value='close' />"; echo "<td width='16' align='middle' valign='middle' bgcolor='#ffffff'><input type='image' src='images/down.png' alt='Close'></td>"; echo "</form"; } } if ( $row[haschildren] == FALSE) { echo "<td width='16' valign='top' bgcolor='#ffffff'></td>"; } // add sub idea button echo "<form action='add_child.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<td width='16' align='center' valign='middle' bgcolor='#ffffff'><input type='image' src='images/add.png' alt='Add Child'></td>"; echo "</form"; //echos the title and content of the idea echo "<td width='180' valign='top' bgcolor='#666666'>".$row['title']."</td>"; echo "<td valign='top' bgcolor='#666666'>"; echo $row['content']; if ( $row[hasduedate] == "true") { // include "timer/timer.php"; echo "</td>"; } else { echo "</td>"; } //echo "</td>"; // echos the UP and DOWN rank buttons and form if ( $row[rank] > 1) { echo "<form action='idea_rank.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='direction' type='hidden' value='up' />"; echo "<td width='16' valign='middle' bgcolor='#666666'><input type='image' src='images/up.png' alt='Up'></td>"; echo "</form"; } if ( $row[rank] < $num_rows) { echo "<form action='idea_rank.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='direction' type='hidden' value='down' />"; echo "<td width='16' valign='middle' bgcolor='#666666'><input type='image' src='images/down.png' alt='Down'></td>"; echo "</form"; } echo "<form action='edit_idea.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/edit.png' alt='Edit'></td>"; echo "</form"; echo "<form action='delete_idea.php' method='get'>"; echo "<input name='delete_idea' type='hidden' value=".$row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/delete.png' alt='Delete'></td>"; echo "</form"; echo "</tr>"; // child query $query_children = "SELECT * FROM children"; $children_result = mysql_query($query_children); $children_rows = mysql_num_rows($children_result); //this part displays the children of the item IF it is set to OPEN and IF it has any children. if ( $row[state] == TRUE ) { for ($c=0; $c < $children_rows; $c++) { $children_row = mysql_fetch_array($children_result); if ( $children_row['childof'] == $row['id'] ) { echo "<tr>"; echo "<td width='16' valign='top' bgcolor='#ffffff'></td>"; echo "<td width='16' valign='top' bgcolor='#ffffff'></td>"; echo "<td width='150' valign='top' bgcolor='#999999'>"; echo $children_row['title']; echo "</td>"; echo "<td bgcolor='#999999'>".$children_row['content']."</td>"; // links for editing and deleting each child. echo "<form action='edit_child.php' method='get'>"; echo "<input name='id' type='hidden' value=".$children_row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/edit.png' alt='Edit Child'></td>"; echo "</form"; echo "<form action='delete_child.php' method='get'>"; echo "<input name='parent_id' type='hidden' value=".$row[id]." />"; echo "<input name='delete_child' type='hidden' value=".$children_row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/delete.png' alt='Delete Child'</td>"; echo "</form"; echo "</tr>"; } } } // } echo "</table>"; ?>
  12. Oh it works fine without the javascript. The javascript is a new addition im adding in.
  13. My below todo list code displays all the todo items and children from a DB. I have just added in a live javascript countdown so you can set a date for a todo item and have a live countdown of how long you have left to complete the todo item. The countdown script that pulls the date from the DB and creates the countdown <div> seems to work fine. But it throws the php into a infinite loop that starts echoing out line after line of table rows. Display Code: All the extra table rows are echoed out right after the include "menu.php" wich is just a button to add a new todo item. The include for the timer is farther down at line 131. <link rel="shortcut icon" href="images/favicon.ico" > <?php error_reporting(E_All); session_start(); session_register('sort'); if ($_session['sort'] == NULL) { $_session['sort'] = $HTTP_GET_VARS[sort]; } ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Idea Box</title> <style type="text/css"> <!-- td,th { font-size: 10px; font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; } body { font-size: 10px; font-family: Arial, Helvetica, sans-serif; } a:link { color: #FFFFFF; } a:visited { color: #FFFFFF; } a:hover { color: #666666; } a:active { color: #FFFFFF; } .menu_text {color: #000000} --> </style> </head> <?php include 'dbconnect.php'; include 'menu.php'; if ( $_session['sort'] == NULL) { $_session['sort'] = "title_ascending"; } if ( $_session['sort'] == "title_ascending" ) { $query = "SELECT * FROM ideas ORDER BY rank ASC"; } else if ( $_session['sort'] = "title_descending") { $query = "SELECT * FROM ideas ORDER BY rank DESC"; } //echo $_session['sort']; $result = mysql_query($query); $rows = mysql_num_rows($result); echo "<table width='100%' border='0' cellspacing='1'>"; for ($i=0; $i <$rows; $i++) { $row = mysql_fetch_array($result); $num_rows = mysql_num_rows($result); echo "<tr>"; /// changes the state of viewing childen IF the idea has children if ( $row[haschildren] == TRUE) { if ( $row[state] == FALSE) { echo "<form action='state.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='state' type='hidden' value='open' />"; echo "<td width='16' align='center' valign='middle' bgcolor='#ffffff'><input type='image' src='images/right.png' alt='Open'></td>"; echo "</form"; } if ( $row[state] == TRUE) { echo "<form action='state.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='state' type='hidden' value='close' />"; echo "<td width='16' align='middle' valign='middle' bgcolor='#ffffff'><input type='image' src='images/down.png' alt='Close'></td>"; echo "</form"; } } if ( $row[haschildren] == FALSE) { echo "<td width='16' valign='top' bgcolor='#ffffff'></td>"; } // add sub idea button echo "<form action='add_child.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<td width='16' align='center' valign='middle' bgcolor='#ffffff'><input type='image' src='images/add.png' alt='Add Child'></td>"; echo "</form"; //echos the title and content of the idea echo "<td width='180' valign='top' bgcolor='#666666'>".$row['title']."</td>"; echo "<td valign='top' bgcolor='#666666'>"; echo $row['content']; if ( $row[hasduedate] == "true") { include "timer/timer.php"; echo "</td>"; } else { echo "</td>"; } //echo "</td>"; // echos the UP and DOWN rank buttons and form if ( $row[rank] > 1) { echo "<form action='idea_rank.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='direction' type='hidden' value='up' />"; echo "<td width='16' valign='middle' bgcolor='#666666'><input type='image' src='images/up.png' alt='Up'></td>"; echo "</form"; } if ( $row[rank] < $num_rows) { echo "<form action='idea_rank.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<input name='direction' type='hidden' value='down' />"; echo "<td width='16' valign='middle' bgcolor='#666666'><input type='image' src='images/down.png' alt='Down'></td>"; echo "</form"; } echo "<form action='edit_idea.php' method='get'>"; echo "<input name='id' type='hidden' value=".$row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/edit.png' alt='Edit'></td>"; echo "</form"; echo "<form action='delete_idea.php' method='get'>"; echo "<input name='delete_idea' type='hidden' value=".$row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/delete.png' alt='Delete'></td>"; echo "</form"; echo "</tr>"; // child query $query_children = "SELECT * FROM children"; $children_result = mysql_query($query_children); $children_rows = mysql_num_rows($children_result); //this part displays the children of the item IF it is set to OPEN and IF it has any children. if ( $row[state] == TRUE ) { for ($c=0; $c < $children_rows; $c++) { $children_row = mysql_fetch_array($children_result); if ( $children_row['childof'] == $row['id'] ) { echo "<tr>"; echo "<td width='16' valign='top' bgcolor='#ffffff'></td>"; echo "<td width='16' valign='top' bgcolor='#ffffff'></td>"; echo "<td width='150' valign='top' bgcolor='#999999'>"; echo $children_row['title']; echo "</td>"; echo "<td bgcolor='#999999'>".$children_row['content']."</td>"; // links for editing and deleting each child. echo "<form action='edit_child.php' method='get'>"; echo "<input name='id' type='hidden' value=".$children_row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/edit.png' alt='Edit Child'></td>"; echo "</form"; echo "<form action='delete_child.php' method='get'>"; echo "<input name='parent_id' type='hidden' value=".$row[id]." />"; echo "<input name='delete_child' type='hidden' value=".$children_row[id]." />"; echo "<td width='16' valign='middle' bgcolor='#ffffff'><input type='image' src='images/delete.png' alt='Delete Child'</td>"; echo "</form"; echo "</tr>"; } } } // } echo "</table>"; ?> JavaScript timer: <?php //$date = $HTTP_GET_VARS[date]; //$hours = $HTTP_GET_VARS[hours]; //$minutes = $HTTP_GET_VARS[minutes]; //get date from DB include "../dbconnect.php"; //SELECT DATE_FORMAT(myDateField, '%d-%m-%Y') FROM myTable //gets the idea background color from DB //$query = "SELECT DATE_FORMAT(duedate, '%d-%m-%Y') FROM ideas WHERE id='18'"; $query = "SELECT duedate FROM ideas WHERE id = '18'"; //$row['id']"; $result = mysql_query($query); $rows = mysql_fetch_array($result); $duedate = $rows[0]; //echo $duedate; //echo "<br>"; $due_date = date('F j Y H:i:s',strtotime($duedate)); //echo "<br>"; //echo $due_date; //2007-12-28 14:59:59 //$due_date = $date." ".$hours.":".$minutes.":00"; //fake $due_date for testing $due_date = "January 1 2008 00:00:00"; $bg_color = "#FF0000"; ?> <!--<!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>--> <style style="text/css"> .custom { color:#FFFFFF; font: bold 20px Arial, Helvetica, sans-serif; background-color:<?php echo $bg_color;?>; } .lcdstyle{ /*Example CSS to create LCD countdown look*/ background-color:black; color:yellow; font: bold 18px MS Sans Serif; padding: 3px; } .lcdstyle sup{ /*Example CSS to create LCD countdown look*/ font-size: 80% } </style> <script type="text/javascript"> /*********************************************** * Dynamic Countdown script- © Dynamic Drive (http://www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ function cdtime(container, targetdate){ if (!document.getElementById || !document.getElementById(container)) return this.container=document.getElementById(container) this.currentTime=new Date() this.targetdate=new Date(targetdate) this.timesup=false this.updateTime() } cdtime.prototype.updateTime=function(){ var thisobj=this this.currentTime.setSeconds(this.currentTime.getSeconds()+1) setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second } cdtime.prototype.displaycountdown=function(baseunit, functionref){ this.baseunit=baseunit this.formatresults=functionref this.showresults() } cdtime.prototype.showresults=function(){ var thisobj=this var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds if (timediff<0){ //if time is up this.timesup=true this.container.innerHTML=this.formatresults() return } var oneMinute=60 //minute unit in seconds var oneHour=60*60 //hour unit in seconds var oneDay=60*60*24 //day unit in seconds var dayfield=Math.floor(timediff/oneDay) var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour) var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute) var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute)) if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level hourfield=dayfield*24+hourfield dayfield="n/a" } else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level minutefield=dayfield*24*60+hourfield*60+minutefield dayfield=hourfield="n/a" } else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level var secondfield=timediff dayfield=hourfield=minutefield="n/a" } this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield) setTimeout(function(){thisobj.showresults()}, 1000) //update results every second } /////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW////////////////////////////// //Create your own custom format function to pass into cdtime.displaycountdown() //Use arguments[0] to access "Days" left //Use arguments[1] to access "Hours" left //Use arguments[2] to access "Minutes" left //Use arguments[3] to access "Seconds" left //The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown() //For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a" //For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc function formatresults(){ if (this.timesup==false){//if target date/time not yet met var displaystring="<span class='custom'>"+arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds</span>" } else{ //else if target date/time met var displaystring="Future date is here!" } return displaystring } </script> <!--<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Count Down!</title> </head> <body>--> <div id="countdowncontainer"></div> <!-- <div id="countdowncontainer2"></div> --> <script type="text/javascript"> var futuredate=new cdtime("countdowncontainer", "<?php echo $due_date;?>") futuredate.displaycountdown("days", formatresults) <!-- --> </script> <!--</body> </html>--> The only thing I can think of is that the JavaScript is breaking the loop and causing it to go on and on and on? But if this is so I do not know why or how to fix it. Any idea? Thanks for your time, ian
  14. I changed it to include "../dbconnect.php"; and it seems to work. That is what it was originally so I dunno...
  15. allow_url_include does not exist in my php.ini file. I did not make any changed it was always set to ON. And have restarted WAMP a couple times.
  16. I am receiving this error: Warning: include() [function.include]: URL file-access is disabled in the server configuration in C:\www\idea\timer\timer.php on line 9 Line 9 of my code is: include "http://localhost/idea/dbconnect.php"; I checked my php.ini and allow_url_fopen is on. allow_url_fopen = On Am running WAMP. Any ideas?
  17. Thanks, Im playing with the SELECT DATE_FORMAT mysql now.
  18. My below code to format the time in a DB echo's two different times. The first date being correct. the date is stored in the db as a DATETIME value. $query = "SELECT duedate FROM ideas WHERE id = '18'"; $result = mysql_query($query); $rows = mysql_fetch_array($result); $duedate = $rows[0]; echo $duedate; echo "<br>"; $duedate = date('F j Y H:i:s',$duedate); echo "<br>"; echo $duedate; exit(); Output: 2007-12-28 14:59:59 December 31 1969 16:33:27 Any reason why they are different? Am I using date() incorrectly? Thanks for your time, ian
  19. That did not work. And I am not sure I understand it. I am not sure why people post bits of code in the help forum where those of us who need help don't know what we are doing. I used the below instead: include 'dbconnect.php'; //gets the idea background color from DB $query = "SELECT idea_bg_color FROM settings LIMIT 1"; $result = mysql_query($query); $rows = mysql_fetch_array($result); $idea_bg_color = $rows[0]; //gets the child background color from DB $query = "SELECT child_bg_color FROM settings LIMIT 1"; $result = mysql_query($query); $rows = mysql_fetch_array($result); $child_bg_color = $rows[0]; echo $idea_bg_color; echo "<br>"; echo $child_bg_color; exit;
  20. I have a table called settings that has simple one field rows to store the value for that settings: Field: value: idea_bg_color 99999 child_bg_color 66666 and so on. What is the best way to pull the value from just the one single row/field? Thanks for your time, ian
  21. My script for returning the mime type of a file does not seem to work: $handle = finfo_open(FILEINFO_MIME); echo $mime_type = finfo_file($handle,$file_name); exit(); Errors: Warning: finfo_open() [function.finfo-open]: Failed to load magic database at '(null)'. in C:\www\idea\imagebox\add_image.php on line 147 Warning: finfo_file(): supplied argument is not a valid file_info resource in C:\www\idea\imagebox\add_image.php on line 148 I did have to turn on php_fileinfo in WAMP for this. Is there something else I need to turn on? Thanks
  22. I am now getting a similar parse error. The below code worked once. Then I tried to add additional image/types to the upload script in the if statement and it failed. Even after removing new code. Error: Parse error: syntax error, unexpected '[', expecting ')' in C:\www\idea\imagebox\add_image.php on line 61 Line 61 Is first line in upload function: function upload_image($_FILES['imagefile'],$image_to_thumbnail) Full code: <style type="text/css"> <!-- input { color: #000000; background: #FFFFFF; border: 1px solid #000000; font-size: 10px; font-family: Arial, Helvetica, sans-serif; } .input_images { vertical-align:middle; color: #000000; background: #FFFFFF; border: 0px solid #FFFFFF; font-size: 10px; font-family: Arial, Helvetica, sans-serif; } --> </style> <form name="copyimage" method="post" action="copy.php" enctype="multipart/form-data"> <input name="action" type="hidden" value="copy" /> <input name="url" type="text" value="" size="100"><input name="filename" type="text" value="" size="20"> <input name="action" type="hidden" value="copy"> <input type="image" class="input_images" src="../images/add.png" alt="Add"> </form> <form name="uploadimage" method="post" action="upload.php" enctype="multipart/form-data"> <input name="imagefile" type="file" size="100"> <input name="Upload" type="submit" value="upload" /> </form> <?php $action = $HTTP_POST_VARS[action]; if ($action == "copy") { copy_image( $file_name ); } if ($action == "upload") { upload_image( $imagefile ); } ?> <?php //upload image function function upload_image($_FILES['imagefile'],$image_to_thumbnail) { ini_set('display_errors', 1); error_reporting(E_ALL); //$submit = $_POST['Submit']; if (empty($_FILES['imagefile'])) { echo "<br><br>"; echo "Please choose a image to upload..."; die; } if(!empty( $_FILES['imagefile'] )) { //If the Submitbutton was pressed do: if ($_FILES['imagefile']['type'] == "image/jpeg") { $_FILES['imagefile']['name'] = str_replace(" ", "_", $_FILES['imagefile']['name']); copy ($_FILES['imagefile']['tmp_name'], "images/full/".$_FILES['imagefile']['name']) or die ("Could not copy"); echo "<br><br>"; echo "<b>File Uploaded...</b>"; } else { echo "<br><br>"; //echo "Could Not Copy... (".$_FILES['imagefile']['name'].")<br>"; echo "Could Not Copy... <br>"; die; } } echo "<br>"; $image_to_thumbnail = $_FILES['imagefile']['name']; //echo $image_to_thumbnail; include "resize_image.php"; echo "image uploaded"; echo "<br>"; echo "<img src=images/thumbs/t_".$image_to_thumbnail." />"; echo "<br>"; echo "<img src=images/full/".$image_to_thumbnail." />"; } ?> <?php //function to copy image function copy_image($url, $file_name, $image_to_thumbnail) { $url = $HTTP_POST_VARS[url]; $file_name = $HTTP_POST_VARS[filename]; if ($url == "") { echo "You must enter a url. "; echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>"; } if ($file_name == "") { echo "You must name the file. "; echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>"; exit(); } if ($url != "") { copy( $url, "images/full/".$file_name ); $image_to_thumbnail = $file_name; include "resize_image.php"; echo "image coppied"; echo "<br>"; echo "<img src=images/thumbs/t_".$image_to_thumbnail." />"; echo "<br>"; echo "<img src=images/full/".$image_to_thumbnail." />"; } } ?> Thanks in advance.
  23. Oh yea... *hands head in shame* Thanks!
  24. My below code is generating this parse error: Parse error: syntax error, unexpected ';', expecting '{' in C:\www\idea\imagebox\add_image.php on line 45 Line 45 is: function copy_image( $file_name ); $action = $HTTP_POST_VARS[action]; if ($action == "copy") { function copy_image( $file_name ); } if ($action == "upload") { function upload_image( $imagefile ); } Functions below. Any dieas?: Thanks <?php //upload image function function upload_image($imagefile,$image_to_thumbnail) { ini_set('display_errors', 1); error_reporting(E_ALL); //$submit = $_POST['Submit']; if (empty($_FILES['imagefile'])) { echo "<br><br>"; echo "Please choose a image to upload..."; die; } if(!empty( $HTTP_POST_VARS['imagefile'] )) { //If the Submitbutton was pressed do: if ($_FILES['imagefile']['type'] == "image/jpeg") { $_FILES['imagefile']['name'] = str_replace(" ", "_", $_FILES['imagefile']['name']); copy ($_FILES['imagefile']['tmp_name'], "images/full/".$_FILES['imagefile']['name']) or die ("Could not copy"); echo "<br><br>"; echo "<b>File Uploaded...</b>"; } else { echo "<br><br>"; //echo "Could Not Copy... (".$_FILES['imagefile']['name'].")<br>"; echo "Could Not Copy... <br>"; die; } } echo "<br>"; $image_to_thumbnail = $_FILES['imagefile']['name']; //echo $image_to_thumbnail; include "resize_image.php"; echo "image uploaded"; echo "<br>"; echo "<img src=images/thumbs/t_".$image_to_thumbnail." />"; echo "<br>"; echo "<img src=images/full/".$image_to_thumbnail." />"; } ?> <?php //function to copy image function copy_image($url, $file_name, $image_to_thumbnail) { $url = $HTTP_POST_VARS[url]; $file_name = $HTTP_POST_VARS[filename]; if ($url == "") { echo "You must enter a url. "; echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>"; } if ($file_name == "") { echo "You must name the file. "; echo "<meta http-equiv='REFRESH' content=3;url=add_image.php>"; exit(); } if ($url != "") { copy( $url, "images/full/".$file_name ); $image_to_thumbnail = $file_name; include "resize_image.php"; echo "image coppied"; echo "<br>"; echo "<img src=images/thumbs/t_".$image_to_thumbnail." />"; echo "<br>"; echo "<img src=images/full/".$image_to_thumbnail." />"; } } ?>
  25. Changed it to: if(!empty( $_POST['imagefile'] )) { //If the Submitbutton was pressed do: still no luck.
×
×
  • 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.