PHP - Time Problem Driving Me Crazy
Okay here's the simple thing I'm trying to do. I have a time in a db on my server .. let's say its March 1st 2011 at 12:00AM. This time is dynamically set by the server, so it's on server time. Now, lets say today is Feb 28th 2011 at 12:00AM on the server. I'm trying to write a dynamic script that will count down that time .. in this case I would want to show 23:59:59.
Every count down script i've found online gives me an option to use local time (browser) or server time. Each time i plug in server time it is always set to my browse time ... I echo everything out and I basically get this: Server time: Feb 28th 2011 at 12:00AM My browser time: Feb 28th 2011 at 2:00AM Script time remaining: 21:59:59 So why does this keep happening? When I echo the date() from the server it's always 2 hours ahead of my time but the script never adjusts. Any ideas or does anyone know of a good working script? I'm on eastern time and the server is on pacific. Here's my last try, you'll see I place the php date into this towards the bottom but I've also tried jquery and SSI methods too. <!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>Untitled Document</title> </head> <body> <script language="JavaScript"> TargetDate = "2/1/2011 12:00 AM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"> */ function calcage(secs, num1, num2) { s = ((Math.floor(secs/num1))%num2).toString(); if (LeadingZero && s.length < 2) s = "0" + s; return "<b>" + s + "</b>"; } function CountBack(secs) { if (secs < 0) { document.getElementById("cntdwn").innerHTML = FinishMessage; return; } DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000)); DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24)); DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60)); DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60)); document.getElementById("cntdwn").innerHTML = DisplayStr; if (CountActive) setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod); } function putspan(backcolor, forecolor) { document.write("<span id='cntdwn' style='background-color:" + backcolor + "; color:" + forecolor + "'></span>"); } if (typeof(BackColor)=="undefined") BackColor = "white"; if (typeof(ForeColor)=="undefined") ForeColor= "black"; if (typeof(TargetDate)=="undefined") TargetDate = "12/31/2020 5:00 AM"; if (typeof(DisplayFormat)=="undefined") DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; if (typeof(CountActive)=="undefined") CountActive = true; if (typeof(FinishMessage)=="undefined") FinishMessage = ""; if (typeof(CountStepper)!="number") CountStepper = -1; if (typeof(LeadingZero)=="undefined") LeadingZero = true; CountStepper = Math.ceil(CountStepper); if (CountStepper == 0) CountActive = false; var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990; putspan(BackColor, ForeColor); var dthen = new Date(TargetDate); var dnow = new Date("<!--config timefmt='%c' --><!--echo var='DATE_LOCAL' -->"); if(CountStepper>0) ddiff = new Date(dnow-dthen); else ddiff = new Date(dthen-dnow); gsecs = Math.floor(ddiff.valueOf()/1000); CountBack(gsecs); </script> <br /> <?php $now = new DateTime(); echo $now->format("M j, Y H:i:s O")."\n"; ?> </body> </html> Similar TutorialsI'm trying to setup my database class so that by default it will create all of the tables and triggers required for my application to run. I've got everything working except for it adding the trigger. Here's the relevant code (slightly obfuscated for security reasons): private function check_consistency() { $database_query = <<<QUERY CREATE TABLE IF NOT EXISTS d2b_users ( id INT NOT NULL AUTO_INCREMENT, obfuscated INT NOT NULL, obfuscated VARCHAR(50) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated BOOL NOT NULL DEFAULT '1', UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS d2b_statistics ( id INT NOT NULL, obfuscated BIGINT NOT NULL DEFAULT '0', UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; delimiter | CREATE TRIGGER d2b_auto_statistics AFTER INSERT ON d2b_users FOR EACH ROW BEGIN INSERT INTO d2b_statistics SET id = NEW.id; END; | delimiter ; QUERY; if(!$consistency = $this->link->multi_query($database_query)) { die("Failed to create/verify the default database tables."); } return true; } I've also tried removing the delimiter and the colon after the INSERT line in the trigger and I still can't get it to add properly. What's annoying is that I'm able to take the code for the trigger from above and go into phpmyadmin and paste it into the SQL and it will add and work correctly. However, I'm trying to get my class to do that automatically so the php application automatically installs itself on other servers. What am I doing wrong? hi guys when a match is over, two result fields have to be edited the first update goes well but the second one is failing, not allways, sometimes it gives the loser xp, but not the winner (with two players) the script should give the winner 100 xp second 95, third 90,... only the first two controls at the end are working the thirth one is not, and its being used to make the first two so it is doing its job there ... <?php include("./includes/egl_inc.php"); $secure = new secure(); $secure->secureGlobals(); page_protect(); global $config; $matchidcheck = $_SESSION['matchid']; $maks = '100'; $players=mysql_query("SELECT playerid FROM ffa_points WHERE matchid='$matchidcheck' order by killsdeaths DESC"); while(list($playerid)=mysql_fetch_array($players)) { $playerspoints=mysql_query("SELECT points FROM members WHERE id='$playerid'"); while(list($points)=mysql_fetch_row($playerspoints)) { $userpoints = $points; } $newpoints = $userpoints + $maks; mysql_query("UPDATE members SET points = $newpoints WHERE id='$playerid'"); mysql_query("UPDATE ffa_points SET xppoints = $maks WHERE id='$playerid' and matchid='$matchidcheck'"); if ($totalxp > 51) { $maks = $maks - 5; } } $mes="$newpoints $points $maks All Results have been stored succesfully !! Thank You !"; return success($mes,'./ffamatchesarchive.php'); include("$config"); ?> any help would be greatly appreciated thanks Hello, If anyone can help please let me know. The 2 files below are what's used to render the "Frickster's ListRave Posts" at the following URL http://www.listrave.com/member/profile.php?id=24. You can see that under Antiques it lists the same ads under both York and Altoona. The script is identifying all ads posted by User ID 24 but I don't know why it is duplicating those ads in the 2 different cities. There should actually be 2 ads for York and one for Altoona. The code is below. Again, please help Here's the code to pull the info from the data base (called memberall_listings.php) $conn = mysql_connect($dbhost1, $dbuser1, $dbpass1) or die ('Error connecting to mysql'); mysql_select_db($dbname1) or die('Could not connect: ' . mysql_error()); $tables = mysql_list_tables($dbname1); while (list($table) = mysql_fetch_row($tables)) { $site["tablename"][] = $table; } if($_REQUEST["id"]!='') $getmemberId = $_REQUEST["id"]; else $getmemberId = $_SESSION["memberid"]; //$x = getTableDetailsByTableName1(""); // echo count($site["tablename"]); $zz=-1; for($ww=0;$ww<count($site["tablename"]);$ww++) { $ValidTable = array("baltperm4w", "balt_yellowpages","boats"); if(!in_array($site["tablename"][$ww],$ValidTable)) { if (count(getTableDetailsByTableName2($site["tablename"][$ww])) >0) $zz++; for($kk=0;$kk<count(getTableDetailsByTableName2($site["tablename"][$ww]));$kk++) { // echo $site["tablename"][$zz]."<br></br>"; $getTableDetails = getTableDetailsByTableName($site["tablename"][$ww],$kk); //echo $getTableDetails["city"]; if ($kk > 0) if ($getTableDetails['city']==$lastcity && $getTableDetails['state']==$laststate) { continue; } $getAllArray[$zz][$kk]["Titlename"] = "<a href='http://www.listrave.com'>ListRave</a> --> <a href=".$getTableDetails["stateurl"].">".$getTableDetails["state"]."</a> --> <a href=".$getTableDetails["cityurl"].">".mysql_real_escape_string($getTableDetails["city"])."</a> --> <a href=".$getTableDetails["maincaturl"].">".$getTableDetails["maincat"]."</a> --> <a href=".$getTableDetails["caturl"].">".$getTableDetails["cat"]."</a>"; $getAllArray[$zz][$kk]["PostURL"] = $getTableDetails["SitePostUrl"]; $getAllArray[$zz][$kk]["AgeFormat"] = $getTableDetails["DisplayFormat"]; $getAllArray[$zz][$kk]["TableName"] = $site["tablename"][$ww]; $getAllArray[$zz][$kk]["SiteRealPath"] = $getTableDetails["SiteRealPath"]; $lastcity = $getTableDetails["city"]; $laststate = $getTableDetails["state"]; $GetAdlists[$zz]["MainArray"] = GetMemberAdLists($site["tablename"][$ww],$getmemberId); if($GetAdlists[$zz]["MainArray"]!=""){ $getAllArray[$zz][$kk]["ArrayExist"] = "Yes"; }else{ $getAllArray[$zz][$kk]["ArrayExist"] = "No"; } for($k=0;$k<count($GetAdlists[$zz]["MainArray"]);$k++) { $getdate = explode(",",$GetAdlists[$zz]["MainArray"][$k]["Posted_date"]); $getAllArray[$zz][$kk][$k]['day'] = date("l",strtotime($getdate[0])); $getAllArray[$zz][$kk][$k]['month'] = date("F",strtotime($getdate[0])); $getAllArray[$zz][$kk][$k]['date'] = date("d",strtotime($getdate[0])); $getAllArray[$zz][$kk][$k]['ListArray'] = getMemberAddetails($getdate[0],$site["tablename"][$ww],$getmemberId, $getTableDetails["city"], $getTableDetails["state"]); for($mn=0;$mn<count($getAllArray[$zz][$kk][$k]['ListArray']);$mn++) { if($getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture0"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture1"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture2"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture3"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture4"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture5"]!='') $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["ImageArray"] = 'Yes'; else $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["ImageArray"] = 'No'; } } } } } /* if($_SERVER['REMOTE_ADDR'] = '122.165.56.46') { printArray($getAllArray); exit; } */ function SelectQry1($Qry) { $result = mysql_query($Qry) or die ("QUERY Error:".$Qry."<br>".mysql_error()); $numrows = mysql_num_rows($result); if ($numrows == 0){ return; } else { $row = array(); $record = array(); while ($row = mysql_fetch_array($result)){ $record[] = $row; } } return $record; } function getTableDetailsByTableName($tablename, $kk) { global $global_config; $Qry = "select * FROM ".$tablename.""; $getListingdetail = SelectQry1($Qry); return $getListingdetail[$kk]; } function getTableDetailsByTableName2($tablename) { global $global_config; $Qry = "select * FROM ".$tablename.""; $getListingdetail = SelectQry1($Qry); return $getListingdetail; } function GetMemberAdLists($tablename,$getmemberId) { global $global_config; $Qry = "select Posted_date FROM ".$tablename." where memberid='".$getmemberId."' group by SUBSTRING_INDEX(Posted_date,',',1) Order by Posted_date DESC"; $getimagedetail = SelectQry1($Qry); return $getimagedetail; } function getMemberAddetails($date,$tablename,$getmemberId) { global $global_config; $Qry = "select * from ".$tablename." WHERE `Posted_date` like '%".$date."%' AND ActivationStatus = 'Active' AND PublishedStatus='Active' AND memberid='".$getmemberId."' group by Posted_date Order by Ident DESC"; $getimagedetail = SelectQry1($Qry); return $getimagedetail; } ?> Here's the code to display it. Remember, this is just for "Frickster's ListRave Posts" <?php // start session ob_start(); session_start(); include "../includes/config.php"; //include('incsec/inccheckifadmin.php'); include ('incsec/incconn.php'); include ('incsec/incsettings.php'); include ('incfunctions.php'); if($_REQUEST["id"]!='') $ActiveMemberID = $_REQUEST["id"]; else $ActiveMemberID = $_SESSION["memberid"]; $query="SELECT * FROM tblmembers where memberid = '".$ActiveMemberID."'"; $result11 = mysql_query($query,$dbconnection); $members = mysql_fetch_array($result11); $pagetitle = 'ListRave - '.$members["username"]." 's".' Profile Page'; include("memberall_business.php"); include('memberall_listings.php'); //printArray($getAllArray); //exit; ?> <?php include('header_member2.php') ?> <div style="height:50px;"> </div> <table border="0" cellpadding="2" cellspacing="0" width="80%" align="center"> <tr> <td valign="top" width="30%" align="left"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" align="left"> <table width="100%"> <tr> <td valign = "top" style="text-align: center;"> <?php include ('incsec/incconn.php'); $dbconnection = mysql_connect($dbhost,$dbusername,$dbpassword); mysql_select_db($database,$dbconnection); $query="SELECT * FROM tblmembers where memberid = '".$ActiveMemberID."'"; $result = mysql_query($query,$dbconnection); $numrecs=mysql_num_rows($result); $myrow = mysql_fetch_array($result); $currentmemberid = $myrow['memberid']; $qry="SELECT * FROM tbl_listrave_ad where memberid = '".$ActiveMemberID."' and PublishedStatus='Active'"; $result1 = mysql_query($qry,$dbconnection); $getcnt =mysql_num_rows($result1); ?> <?php if($numrecs!=0) { ?> <table height="100" width="90%" border="0" cellpadding="6" cellspacing="0" align="center"> <tr> <td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #0166FF;"> <tr> <td align="left" class="profilefheader" width="100%" colspan="2" style="padding-left:5px; padding-top:0px; height:20px; line-height:20px;" valign="middle"><?php echo $myrow["username"]; ?>'s Profile</td> </tr> <tr> <td align="left" valign="top"> <table width="100%" border="0" cellpadding="10" cellspacing="0" id="profilecontainer" align="left" style="margin-left: 10%"> <tr> <td valign = "top" width="10%"> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="20%" align="left" valign="top" style="padding-right:35px"> <?php if($myrow["memberphoto"]!='') { ?> <a target="_blank" href="imageview.php?id=<?php echo $myrow["memberid"]; ?>"> <img width="180" height="180" class="Imageborder" src="<?php echo $config["sitepath"]."memberphotos/".$myrow["memberphoto"].""; ?>"> </a> <?php } else { ?> <img src="no-image.gif" border="0" width="180" height="180" class="Imageborder" /> <?php } ?> </td> </tr> <tr> <td height="30"> </td> </tr> <?php /*?><tr> <td width="80%" align="center" valign="top"> <?php if($myrow["memberphoto"]!='') { ?> <img src="upload.gif" border="0" /> <?php } else { ?> <img src="change-photo.gif" border="0" /> <?php } ?> </td> </tr><?php */?><tr valign="bottom"><td> </td></tr><tr><td align="left"><img src="addcontact.gif" alt="Add This Member To Your Contacts" /></td></tr></table> </td> <td valign = "top"> <table width="90%" border="0" cellpadding="6" cellspacing="0" align="left"> <tr> <td align="left" valign="top" colspan="2"> <table width="90%" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" width="15%" nowrap="nowrap"> <span id="profilecontainer">Personal Information </span> </td> <td width="88%" valign="top"> <div style="border-top: #CCCCCC solid 1px; position:relative; top:7px;"> </div> </td> </tr> </table> </td> </tr> <?php if($myrow["firstname"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>First Name</strong> </td> <td align="left" valign="top"> <?php echo $myrow["firstname"]; ?> </td> </tr> <?php } ?> <?php if($myrow["othernames"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Last Name</strong> </td> <td align="left" valign="top"> <?php echo $myrow["othernames"]; ?> </td> </tr> <?php } ?> <?php if($myrow["gender"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Gender</strong> </td> <td align="left" valign="top"> <?php echo $myrow["gender"]; ?> </td> </tr> <?php } ?> <?php if($myrow["age"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Age</strong> </td> <td align="left" valign="top"> <?php echo $myrow["age"]; ?> </td> </tr> <?php } ?> <?php if($myrow["pobox"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Location</strong> </td> <td align="left" valign="top"> <?php echo $myrow["pobox"]; ?> </td> </tr> <?php } ?> <?php if($myrow["relationship_status"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Relationship Status</strong> </td> <td align="left" valign="top"> <?php echo $myrow["relationship_status"]; ?> </td> </tr> <?php } ?> <?php if($myrow["registrationdate"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Member Since</strong> </td> <td align="left" valign="top"> <?php echo date('M d, Y', strtotime($myrow["registrationdate"])); ?> </td> </tr> <?php } ?> <?php if($myrow["username"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>User Name</strong> </td> <td align="left" valign="top"> <?php echo $myrow["username"]; ?> </td> </tr> <?php } ?> <?php if($myrow["about_me"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>About me</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["about_me"]; ?> </td> </tr> <?php } ?> <?php if($myrow["hobbies"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Hobbies</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["hobbies"]; ?> </td> </tr> <?php } ?> <?php if($myrow["movies"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Favorite Movies</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["movies"]; ?> </td> </tr> <?php } ?> <?php if($myrow["music"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Favorite Music</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["music"]; ?> </td> </tr> <?php } ?> <?php if($myrow["books"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Favorite Books</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["books"]; ?> </td> </tr> <?php } ?> <tr> <td height="15"> </td> </tr> <tr> <td align="left" valign="top" colspan="2"> <table width="90%" border="0" cellpadding="0" cellspacing="0" > <tr> <td valign="top" width="15%" nowrap="nowrap" > <span id="profilecontainer">Contact Information </span> </td> <td width="88%" valign="top"> <div style="border-top: #CCCCCC solid 1px; position:relative; top:7px;"> </div> </td> </tr> </table> </td> </tr> <?php if($myrow["emailaddress"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Email</strong> </td> <td align="left" valign="top"> <?php echo $myrow["emailaddress"]; ?> </td> </tr> <?php } ?> <?php if($myrow["phonenumber"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Mobile Number</strong> </td> <td align="left" valign="top"> <?php echo $myrow["phonenumber"]; ?> </td> </tr> <?php } ?> & Hi People. I am trying to insert data from a form into my database. Now I have the following code to connect to the DB to update a table so I know that I can connect to the DB ok Code: [Select] <?php // this code I got from the new boston, PHP tutorial 25 in selecting a mysql db // opens connection to mysql server $dbc = mysql_connect('localhost', 'VinnyG', 'thepassword'); if (!$dbc) { die("Not Connected:" . mysql_error ()); } // select database $db_selected = mysql_select_db ("sitename",$dbc); if(!$db_selected) { die("can not connect:" . mysql_error ()); } // testing code $query="UPDATE users SET username = 'testing testing' WHERE user_id = '2'"; $result=mysql_query($query); ?> Now here is the code from my form. Code: [Select] </head> <body> <?php //include "connection_file.php" //include "config01.php" $username = "username"; $height_above = "height_above"; $mb_diff = "mb_diff"; $alternative = "alternative"; ?> <form name = 'form1' method = 'post' action='config01.php'> <table width="700" border="1" cellspacing="5" cellpadding="5"> <caption> Submit Your Airfield Details </caption> <tr> <td width="100"> </td> <td width="200">Your Name</td> <td width="200"><input type='text' name='username' maxlength='30'></td> <td width="100"> </td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above'maxlength= '30'></td> <td> </td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff'maxlength='40'></td> <td> </td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' maxlength='30'></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><input type='submit' name='submit' value='post' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> <?php $sql01 = "INSERT INTO users SET user_id = '', username = '$username',height_above = '$height_above', mb_diff = $mb_diff, alternative = $alternative"; $result=mysql_query($sql01); ?> </body> </html> here is the config01.php that the form refers to in the 'action' above. Code: [Select] <?php $host = 'localhost'; $username = 'VinnyG'; $password = 'thepassword'; $db_name = 'sitename'; //connect to database mysql_connect ("$host","$username","password")or die ("cannot connect to server"); mysql_select_db ("db_name") or die ("cannot select DB"); ?> Please could someone look at the above code and tell me where I'm going wrong. I can connect to the DB and update using the top script but I can't submit the form for some reason. I get a "cannot connect to server" message. Please someone help. It's been driving me crazy for the past two days. Regards VinceG http://www.microlightforum.com Ok, so the error I get is Parse error: syntax error, unexpected $end in /home/a3868616/public_html/skin_files/skin_manager.php on line 168. In dreamweaver, it tells me there is an error on line 141, which is the first line to be returned ( Code: [Select] <table cellspacing="0" class="tableborder" width="85%" align="center">) in the contract function. I've looked at this over and over, and I can't find any brackets that aren't closed. All of the lines of code seem to be in their correct syntax. I was thinking maybe the EOF in the else after the while was causing it, but same errors different line numbers when I removed that. What the hell can it be!? The whole php file is below. <?php class skin_manager{ function show(){ global $DB, $projectx, $func, $game; return <<<EOF <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="40%" valign="top"> <table cellspacing="0" class="tableborder" width="100%"> <tr> <td class="mainrow">Manager Page</td> </tr> <tr> <td> <div class="tablepad"> <table cellspacing="0" cellpadding="3" width="100%"> <tr> <td class="row1"><a href="#">Finances</a></td> </tr> <tr> <td class="row2"><a href="manager.php?act=contracts">Contracts</a></td> </tr> <tr> <td class="row1"><a href="#">Holiday Mode</a></td> </tr> </table> </div> </td> </tr> </table> </td> <td width="2%"></td> <td width="40%"> <table cellspacing="0" class="tableborder" width="100%"> <tr> <td class="mainrow">Manager Releases</td> </tr> <tr> <td> <div class="tablepad"> <table cellspacing="0" cellpadding="3" width="100%"> <tr> <td class="rowheader" colspan="2">Singles</td> </tr> <tr> <td class="row2" width="25%">Gold:</td> <td class="row2" width="75%">{$band_name}</td> </tr> <tr> <td class="row1" width="25%">Platinum:</td> <td class="row1" width="75%">{$band_genre}</td> </tr> <tr> <td class="row2" width="25%">Multi-Platinum:</td> <td class="row2" width="75%">{$band_status}</td> </tr> <tr> <td class="row1" width="25%">Number 1:</td> <td class="row1" width="75%">{$band_created}</td> </tr> <tr> <td class="row1" width="25%">Total:</td> <td class="row1" width="75%">{$band_created}</td> </tr> <tr> <td class="rowheader" colspan="2">Albums</td> </tr> <tr> <td class="row2" width="25%">Gold:</td> <td class="row2" width="75%">{$band_name}</td> </tr> <tr> <td class="row1" width="25%">Platinum:</td> <td class="row1" width="75%">{$band_genre}</td> </tr> <tr> <td class="row2" width="25%">Multi-Platinum:</td> <td class="row2" width="75%">{$band_status}</td> </tr> <tr> <td class="row1" width="25%">Number 1:</td> <td class="row1" width="75%">{$band_created}</td> </tr> <tr> <td class="row1" width="25%">Total:</td> <td class="row1" width="75%">{$band_created}</td> </tr> </table> </div> </td> </tr> </table> </td> <td width="18%"></td> </tr> </table> EOF; } // end function show function contract(){ global $DB, $projectx, $func; $contracts_q = $DB->query("SELECT * FROM `contracts` RIGHT JOIN `bands` ON (contracts.contract_band = bands.band_id) LEFT JOIN `labels` ON (contracts.contract_from = labels.label_id) WHERE contracts.contract_manager='{$projectx->member['id']}'"); if($DB->get_num_rows()){ while($row = $DB->fetch_array($contracts_q)){ $pcontracts .= "<tr>"; if($style != 2){ $class = "row2"; $style = 1; }else{ $class = "row1"; $style = 2; } $pcontracts .= "<td class=\"{$class}\" width=\"20%\">{$row['band_name']}</td>"; $pcontracts .= "<td class=\"{$class}\" width=\"20%\">{$row['label_name']}</td>"; $clength = explode(",", $row['contract_length']); $csingles = explode("|", $clength[0]); $calbums = explode("|", $clength[1]); $pcontracts .= "<td class=\"{$class}\" width=\"30%\">{$csingles[0]} singles ({$csingles[1]}% cut), {$calbums[0]} albums ({$calbums[1]}% cut)</td>"; $pcontracts .= "<td class=\"{$class}\" width=\"10%\">{$row['contract_amount']}</td>"; $pcontracts .= "<td class=\"{$class}\" width=\"20%\">Accept / Reject</td>"; $pcontracts .= "</tr>"; } }else{ $pcontracts = <<<EOF <tr> <td class="row2" colspan="5">You have no contracts.</td> </tr> EOF; } return <<<EOF <table cellspacing="0" class="tableborder" width="85%" align="center"> <tr> <td class="mainrow">Contracts</td> </tr> <tr> <td> <div class="tablepad"> <table cellspacing="0" cellpadding="3" width="100%"> <tr> <td class="rowheader" width="20%">Band</td> <td class="rowheader" width="20%">From</td> <td class="rowheader" width="30%">Terms</td> <td class="rowheader" width="10%">Amount</td> <td class="rowheader" width="20%">Decision</td> </tr> </table> </div> </td> </tr> </table> EOF; } // end function contract } // end class skin_manager ?> Hi all, i was trying to include a php file in an index file into another files and those included file is including one file also. But for some reason the database connection file is not included. this is the map structure www/index.php <---- the file that uses include www/newsletter/newsletter.php <---- has a form with action process.php www/newsletter/process.php <--- this has an include referring to database.php www/newsletter/database.php <--- the databasefile This is what i did but it gives a server error in index.php include('newsletter/newsletter.php'); innewsletter.php <form action="newsletter/process.php" method="post"><!--- some form stuff--></form> in process.php include('database.php'); I really don't understand why it doesn't work and it's giving a server error 500. The form loads like it should in the index.php but the rest doesn't any help is appreciated. Hi, The code below is not yet finished but i left it today and went to do something came back and forgot where i left off half way through code. It says Parse error: syntax error, unexpected $end in C:\wamp\www\member\login.php on line 305. Not on line 305 thou as that is the last line. I think i have missed a parentheses or curly bracelet. My eyes are watering now i have looked over and over. Please someone help. Like i say it's not yet finished or formatted to it's best but hopefully one of you people on here can help me Thanks <?php //ob_start(); // Include config.php require_once("".$_SERVER['DOCUMENT_ROOT']."/lib/config.php"); // top.inc.php require_once($top_inc); ?> <!-- Meta start --> <title><?php echo $websitename; ?> - Member Login</title> <meta name="description" content="<?php echo $websitename; ?> - Member Login" /> <meta name="keywords" content="<?php echo $websitename; ?>, login, signup, register, sign in, signin, sign up" /> <!-- Meta end --> <?php // main.inc.php require_once($main_inc); ?> <!-- CONTENT HERE --> <?php // Check if form has been submitted if(isset($_POST['submit']) && $_SERVER['REQUEST_METHOD'] == 'POST'){ # Connect to databse sql_con(); # Get form data and cleanse $username = msqls(trim($_POST['username'])); $password = msqls(trim($_POST['password'])); $ip = msqls($_SERVER['REMOTE_ADDR']); # Validate form data if (utfstrlen($username) < 1) { $error .= "Please enter your username <br />"; } if (utfstrlen($username) > 0 && !preg_match(constant("USERNAME_REGEX"), $username)) { $error .= "Username invalid format <br />"; } if (utfstrlen($password) < 1) { $error .= "Please enter your password <br />"; } if (utfstrlen($password) > 0 && !preg_match(constant('PASSWORD_REGEX'), $password)) { $error .= "Password invalid format<br />"; } # If error founds display them if(isset($error)){ $SiteErrorMessages = "$error"; SiteErrorMessages(); } # else no errors found continue processing else { # Check if user has activated there account $status_check = mysql_query("SELECT username FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_VERIFY")."' LIMIT 1"); # Check if user has requested account to be deleted $delete_check = mysql_query("SELECT username FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_DELETE")."' AND password = '".sha1($password)."' LIMIT 1"); # Check if user has been suspended $username_status_check = mysql_query("SELECT username, suspended_note FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_SUSPENDED")."' AND password = '".sha1($password)."' LIMIT 1"); # Check above queries if error occurs notify user if(!$delete_check || !$status_check || !$username_status_check){ echo '<h1>Oops something went wrong :(</h1>'; $SiteErrorMessages = "Something went wrong while processing your request. Please try again later. <br /> $websitename has been notified of this error and will investigate further."; SiteErrorMessages(); # This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "User Login Failure <br /> A user tried to login but the verify, suspended or delete query check failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); include("$footer_inc"); exit; } # else queries ok continue processing else { # Check delete query if (mysql_num_rows($delete_check) == 1) { echo '<h1>Account Deletion In Process</h1>'; echo "<p><b>Sorry, you cannot login to your account as you requested your account to be deleted.</b> <b>Your account is queued for deletion from the $websitename database and will be deleted within 24 hours.</b></p>"; echo "<p><b>$websitename sent you a confirmation email when you requested your account to be removed.</b> <b>If you did not make this request via your account please <a href=\"../contactus.php\">contact us</a> immediately.</b></p>"; echo "<p><b>Please note that it may not be possible to recover your account as the process is automated.</b></p>"; header( 'refresh: 60; url=$websiteaddress' ); include ("$footer_inc"); exit; } # Check status query elseif (mysql_num_rows($status_check) == 1) { echo "<h1>Account Activation Required</h1>"; echo "<p><b>You must activate your account via email before you can login.</b></p>"; header( 'refresh: 10; url=resendactivationemail.php' ); include ("$footer_inc"); exit; } # Check username status query elseif (mysql_num_rows($username_status_check) == 1) { $row = mysql_fetch_row($username_status_check); echo "<h1>Account Suspended</h1>"; echo "<p>Dear <b>" . $row[0] . "</b>, <br /> Your account has been suspended. The administrator has left the following message:</p>"; $no_suspended_note = "The administrator has not left a message. <br /> If you feel your account has been suspended in error please contact $websitename <a href=\"/contactus.php\">here</a>."; if (utfstrlen($row[1]) < 1) { $SiteWarningMessages = "$no_suspended_note"; SiteWarningMessages(); include ("$footer_inc"); exit; } else { $SiteWarningMessages = " . $row[1] . "; SiteWarningMessages(); echo '<p>If you feel your account has been suspended in error please contact ' . $websitename . ' <a href="/contactus.php">here</a>.<br /> <b>Please include your username when contacting ' . $websitename . '.</b></p>'; include ("$footer_inc"); exit; } } # else user must be ok to login so continue ... else { # Login Query $query = mysql_query("SELECT id, admin, username, first_name, last_name, email, last_visited, date_time, websiteurl, msn, aim, yim, twitter, gender FROM ".constant("TBL_USERS")." WHERE username = '$username' AND password = '".sha1($password)."' LIMIT 1"); # Check login query if(!$query){ echo '<h1>Oops something went wrong</h1>'; $SiteErrorMessages = "Something went wrong while trying to log you in. Please try again later. <br /> $websitename has been notified of this error and will investigate further."; SiteErrorMessages(); // This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "User Login Failure <br /> A user tried to login but the Login Verification Check failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); include("$footer_inc"); exit; } # else login query ok so continue else { # Validate credentials against DB if (mysql_num_rows($query) == 1) { $found_user = mysql_fetch_array($query); # Tell them they are being logged in echo '<h1>Your now being logged in ...</h1>'; $SiteSuccessMessages = '<a href=\"/member/cp.php\">Click here if you do not automatically redirect</a>'; SiteSuccessMessages(); # User logged in succesfully reset failed login number to 0 $failed_login_reset = mysql_query("UPDATE ".constant("TBL_USERS")." SET `failed_login_count` = '0', `ip` = '" . $ip . "' WHERE `username` = '" . $username . "' LIMIT 1"); # check failed login query if(!$failed_login_reset){ // This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "User Login Failure <br /> A user logged in but the failed login reset counter query failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); } # Store all member data into session to use for later on other areas of the website $_SESSION['username'] = $found_user['username']; $_SESSION['id'] = $found_user['id']; $_SESSION['admin'] = $found_user['admin']; $_SESSION['last_visited'] = date('l dS F Y, g:i:s A', $found_user['last_visited']); $_SESSION['first_name'] = $found_user['first_name']; $_SESSION['last_name'] = $found_user['last_name']; $_SESSION['email'] = $found_user['email']; $_SESSION['websiteurl'] = $found_user['websiteurl']; $_SESSION['msn'] = $found_user['msn']; $_SESSION['aim'] = $found_user['aim']; $_SESSION['yim'] = $found_user['yim']; $_SESSION['twitter'] = $found_user['twitter']; $_SESSION['gender'] = $found_user['gender']; $_SESSION['date_time'] = date('l dS F Y, g:i:s A', $found_user['date_time']); $_SESSION['date_time_for_profile'] = $found_user['date_time']; $_SESSION['time'] = time(); if (isset($_GET['redirect'])) { redirect($websiteaddress . $_GET['redirect'], 2); } else { redirect("cp.php", "0"); } include ("$footer_inc"); exit; } # else login details invalid else { # Login Details Invalid Error echo 'Login Details Invalid'; # If user fails 3 logins lock there account $login_failure_query = mysql_query("SELECT username, email, failed_login_count, status FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_ACTIVATED")."' LIMIT 1"); # Check if query ok if(!$login_failure_query){ # This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "Login Failure Query <br /> A user tried to login but the Login Failure Query Check failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); include("$footer_inc"); exit; } # else login_failure_query ok so continue ... else { # Check if (mysql_num_rows($login_failure_query) == 1) { # Fetch user row $row = mysql_fetch_row($login_failure_query); # Store data in variables $username_ = $row[0]; $email = $row[1]; # Increment failed login row by 1 on each failed login $login_count = $row[2] + 1; # Update failed_login_count row each time login fails $update_login_number = mysql_query("UPDATE ".constant("TBL_USERS")." SET `failed_login_count` = '" . $login_count . "' WHERE `username` = '" . $username . "'"); # Fetch total failed logins $login_count_total = $row[2]; } } } } ?> <h1>Login</h1> <form action="login.php<?php if (isset($_GET['redirect'])) { echo "?redirect=" . $_GET['redirect']; } ?>" method="post" id="frmcontact"> <label for="username">Username</label> <input type="text" name="username" id="username" value="<?php if (isset($username)) { echo $username; } ?>" class="textboxcontact" /> <label for="password">Password</label> <input type="password" name="password" id="password" class="textboxcontact" /> <label for="submit"> </label> <input type="submit" name="submit" id="submit" value="Sign In" class="submitcontact" /> </form> <!-- CONTENT FINISH --> <?php // footer.inc.php require_once($footer_inc); //ob_end_flush(); ?> Hey guys, I really hope someone can help me out here. I have been working on my new website all week and am now almost finished. Just need to complete the contact page and touch up a few things... I really dont know php at all to be honest and just found a code somewhere on the net to help me. Heres my problem I have finally got the form to work but i am not recieving the correct data. I only get the email add, subject and messge. I am not getting the name of the sender.. also i really want to add a website field to the code because i do have that on the contact form... please can someone tell me where i am going wrong? the following is the php code i am using... <?php // Contact subject $subject ="Website enquiry"; // Details $message=$_POST[detail]; // Mail of sender $mail_from=$_POST[customer_mail]; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='robin@rdosolutions.com'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> please help me.. i am hoping to put the site live tomorrow... many thanks in advance.. rob Hey guys! The error is that it seems to display EVERYTHING regardless of the if and else statements. Also, it seems to stop evaluating the rest of the document that "includes" this as soon as its done with this one. dbconnect works and all the session vars carry properly... WTF is going on!? <?php session_start(); include 'dbconnect.php'; $username = $_SESSION['username']; $q = mysql_query("SELECT User_type FROM account WHERE username = '$username'") or die(mysql_error()); $permission = mysql_fetch_row($q); $permission = $permission[0]; if(isset($_SESSION['username']) && $permission >= 2){ echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>"; echo $menu001; echo "</span></a></li><li><a href=''><span>"; echo $menu002; echo "</span></a></li><li><a href=''><span>"; echo $menu003; echo "</span></a></li><li><a href=''><span>"; echo $menu004; echo "</span></a></li><li><a href=''><span>"; echo $menu006; echo "</span></a></li>";} elseif($permission <= 1){ echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>"; echo $menu001; echo "</span></a></li><li><a href=''><span>"; echo $menu002; echo "</span></a></li><li><a href=''><span>"; echo $menu003; echo "</span></a></li><li><a href=''><span>"; echo $menu004; echo "</span></a></li>";} else{ echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>"; echo $menu001; echo "</span></a></li><li><a href=''><span>"; echo $menu002; echo "</span></a></li><li><a href=''><span>"; echo $menu003; echo "</span></a></li><li><a href=''><span>"; echo $menu005; echo "</span></a></li>"; echo "<span> <form action='login.php' method='POST'> <input type='text' value='username' name='username'> <input type='text' value='password' name='password'> <input type='submit'> </form> </span> </li> </ul> </div> </div>";} ?> I have a simply script like this: $fh = fopen("test/test.js", 'w+') or die("can't open file"); fwrite($fh, $output); fclose($fh); It ONLY works if the "test" directory has a 777 permissions. Works like a charm then, but the moment it goes to even 775, I get this: Warning: fopen(test/test.js) [function.fopen]: failed to open stream: Permission denied in /var/www/vhosts/mydomain.com/httpdocs/f.php on line 42 Any thoughts? I don't want this folder to remain 777 Thanks I'm trying to get a remote html page but I'm having a really weird problem. I'm using curl for that and I'm getting the page url from an rss item using simpelpie. Code: [Select] $url = $item->get_permalink();//simplepie function echo "<p>Getting $url. </p>"; $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_ENCODING => "", // handle all encodings CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; if($err != 0) echo " $err : $errmsg</p>"; echo $header['content']; My problem is that although the page is loading fine ( no curl errors ) , some tags are missing (and particularly the tags that containing the article content of that page). When I'm hardcoding the url then everything is fine. I tried to print the url that simpepie gets from rss and it's identical with the one that I'm harcoding. So, Code: [Select] $url = $item->get_permalink(); not working Code: [Select] $url = "http://www.the_same_url.com" working. Any help whould be really appreciated. Thanks in advance. I am having a problem I have encounted like no other. I am running a MySQL query from PHP and for some bizarre reason, its just not working... Ok, that sounds really general. lol To start off, here is my database: http://i56.tinypic.com/2hh0up1.png I am writing my own user interface with HTML/PHP/MySQL for every day catalog management: http://i54.tinypic.com/axxsb7.png To catalog a product is done from here (this page works): http://i51.tinypic.com/2e0qs7s.png ETC ... <FORM action="result.html" enctype="multipart/form-data" method="post"> ... ETC ETC ... Name: <INPUT name="name" type="text"> <BR> Brand: <INPUT name="brand" type="text"> <BR> Country of origin: <INPUT name="country" type="text"> <BR> Material: <INPUT name="material" type="text"> <BR> Primary colour: <INPUT name="primarycolour" type="text"> ... ETC result.html: ETC ... $query = "INSERT INTO products(name, brand, country, material, primarycolour) VALUES('".$_POST['name']."', '".$_POST['brand']."', '".$_POST['country']."', '".$_POST['material']."', '".$_POST['primarycolour']."')"; ... ETC To alter a product, you enter in a product ID: http://i56.tinypic.com/2lcsqch.png Code: [Select] <FORM action="dataentry.html" method="post"> <DIV class="drop">Alter product ID: <INPUT name="id" type="text">    <INPUT type="submit" value="Submit"></DIV> The data entry page pulls all the values from the MySQL database and populates them into the INPUT fields, so the user does not have to write them all again: http://i56.tinypic.com/2zh0hgn.png ... ETC echo '<FORM action="result.html" enctype="multipart/form-data" method="post">'; ETC ... ... ETC echo 'Name:'; $query = "select name from products where id=".$_POST['id'].""; $result = mysql_query($query); $row = mysql_fetch_array($result); echo ' <INPUT name="name" type="text" value="'.$row['name'].'">'; echo $query; ETC ... I will now change the value of "Name" from 'a' to 'c' and submit the changes: http://i55.tinypic.com/dzi9hc.png http://i54.tinypic.com/ab5lyg.png Now, you would think the result has been inserted into my database yeah? It failed... but when I enter the same command directly into MySQL. Success! http://i51.tinypic.com/29z5y5x.png Why the F is this happening?! Hi.. I got an issue in getting the total time. I have this code to get the sum of total time: Code: [Select] $result = mysql_query("INSERT INTO payroll.casual_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM payroll.casual_att WHERE DATE_FORMAT(LOGOUT, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') GROUP BY EMP_NO") or die(mysql_error()); Rendered: 09:00:00 09:00:00 09:00:00 08:00:00 08:00:00 07:48:00 and the result of this is 50:48 but I need result is 50:80 the minutes is divided to 60 Is there any way to get the 50:80 result. Thank you so much.. Hi - I have been searching for a way to select the stored time from a database (stored in 24h format - 13:20:00) and display it as 12h format. I have checked a number of forums and nothing quite seems to fit the bill. I would like it to display as 2:00pm, 12:00am, etc. Here is what I have so far: $sql = ('SELECT * FROM events WHERE active="1" AND event_date >= CURRENT_DATE AND MONTH(event_date) = 1 order by event_date ASC, event_start ASC'); $result = mysql_query($sql); $num_rows = mysql_num_rows($result); // Yes Item if (!($num_rows == 0)) { $myrow = mysql_fetch_array($result); echo ('<span class="bold" style="font-size:14px">January</span>'); do { printf ('<span>Event Time: %s', $myrow['event_start']); if ($myrow['event_end'] != '') { printf (' to %s', $myrow['event_end']); } } while ($myrow = mysql_fetch_array($result)); } Right now this just shows the regular 24h format (hh:mm:ss) for any events in the month of January. I would like both "event_start" and "event_end" to show up in 12h format. I have tried a number of things but none of it works. I'm SURE it is something simple that I have missed. Thanks in advance for any help. Hi, I'm preparing a code for an automated email, but the date time is not working correctly. I wanted to do a cron scheduler that emails people twice a day - 9am and 9pm. 9am sends email about records logged starting 9pm yesterday to 9am, while 9pm sends email about records logged from 9:01am to 9:00pm. The database uses date/time, so I was doing an if statement of date time, but I wasn't getting the result I wanted. Sometimes the $now time is not within the yesterday 9pm to the 9pm today range. I don't know what I'm doing wrong, but I'm sure that it has something to do with the if statement, as the some of the $now time enters the else statement Here is my code: <?php $today = date('Y-m-d 00:00:00'); $nineyesterday = date('Y-m-d H:i:s', mktime(date("H") - (date("H") + 6), date("i") - date("i"), date("s") - date("s"), date("m") , date("d"), date("Y"))); $now = date('Y-m-d H:i:s', mktime(date("H") + 13, date("i"), date("s"), date("m") , date("d"), date("Y"))); $nineam = date('Y-m-d 09:00:00'); $nine30 = date('Y-m-d 09:30:00'); $ninepm = date('Y-m-d 18:00:00'); echo '9pm yesterday: '.$nineyesterday; echo '<br/>'; echo '9am: '.$nineam; echo '<br/>'; echo '9pm: '.$ninepm; echo '<br/>'; echo 'now: '.$now; echo '<br/>'; if ((strtotime($now) > strtotime($nineyesterday)) and (strtotime($now) <= strtotime($nineam))) { //count the answers by yes or no echo 'am'; } elseif ((strtotime($now) > strtotime($nineam)) and (strtotime($now) <= strtotime($ninepm))) { //count the answers by yes or no echo 'pm'; } else { echo 'error'; } ?> Thanks in advance ok so im wondering if you all could prob fix this code its not working and when "meta"when it refreshes the page nothing deletes Code: [Select] <?php $host="localhost"; // Host name $username="username"; // Mysql username $password="password"; // Mysql password $db_name="database name"; // Database name $tbl_name="table name"; // Table name // below was a replie from forums. it made alot of problems// foreach($_POST['checkbox'] AS $ID) { $values[] = '\''.intval($ID).'\''; } $values = implode(' , ',$values); $myQuery = "DELETE FROM $tbl_name WHERE id IN ($values)"; if(mysql_query($myQuery)) { header('Location: delete_multiple.php'); } else { echo 'Query failed: "'.$myQuery.'"'; } // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <style> /*table affects look of the whole table look */ table { margin-left: auto; margin-right: auto; border: 1px solid #330000; border-collapse:collapse; width:70%; border-width: 5px 5px 5px 5px; border-spacing: 1px; border-style: outset outset outset outset; border-color: #330000 #330000 #330000 #330000; border-collapse: separate; background-color: #330000; #800517 f535aa #330000 school color #9A0000 school color2 #991B1E school color3 #CCCC99 school color4 #9A0000 } /*th is table header */ th { text-align: left; height: 2.5em; background-color: #330000; color: #FC0; font-size:1.5em; } /*td is table data or the cells below the header*/ td { text-align: left; height:1.0em; font-size:1.0em; vertical-align:bottom; padding:10px; border-width: 5px 5px 5px 5px; padding: 8px 8px 8px 8px; border-style: outset outset outset outset; border-color: #9A0000 #9A0000 #9A0000 #9A0000; background-color: #CCCC99; -moz-border-radius: 0px 0px 0px 0px; } </style> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="form1" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Pick Which Rows you want to delete, Then press delete.</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Lastname</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Email</strong></td> <td align="center" bgcolor="#FFFFFF">delete</td></tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td bgcolor="#FFFFFF"><? echo $rows['id']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['lastname']; ?></td> <td bgcolor="#FFFFFF"><? echo $rows['email']; ?></td> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php // Check if delete button active, start this // edited if($delete){ for($i=0;$i<$count;$i++){ $del_id = $checkbox[$i]; $sql = "DELETE FROM $tbl_name WHERE id='$del_id'"; $result = mysql_query($sql); } // if successful redirect to delete_multiple.php if($result){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=delete_multiple.php\">"; } } mysql_close(); ?> </table> </form> </td> </tr> </table> this is whats wrong with it could i get some help? Warning: Invalid argument supplied for foreach() in /home/sumersadl/public_html/testfile/delete_multiple.php on line 8 Warning: implode() [function.implode]: Invalid arguments passed in /home/sumersadl/public_html/testfile/delete_multiple.php on line 12 Warning: mysql_query() [function.mysql-query]: Access denied for user 'root'@'localhost' (using password: NO) in /home/sumersadl/public_html/testfile/delete_multiple.php on line 16 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/sumersadl/public_html/testfile/delete_multiple.php on line 16 Query failed: "DELETE FROM test_mysql WHERE id IN ()" So the code works right, (I think) but for some reason the way I built it the logic comes back null. I can do All w a specific shift/s, and All with department/s but I can't do All shifts and All departments it doesn't' error either, just brings back nothing, maybe timing out? I'm very new at this so I apologize in advance. Code below ############################################################ <form method="post" action=""> <br><br> <table bordercolor="yellow" border="2"> <tr><td class="line"><b>Start Date:</b></td><td> <input type="text" name="startdate" value="mm/dd/yyyy" /></td></tr> </tr> <tr><td class="line"><b>End Date:</b></td><td> <input type="text" name="enddate" value="mm/dd/yyyy" /></td></tr> </tr> <tr><td class="line"><b>Shift:</b></td><td> <SELECT NAME="shift" > <option selected>Select Shift</option> <option>First</option> <option>Second</option> <option>Third</option> <option>All</option> </SELECT> </td></tr> <tr><td class="line"><b>Department:</b></td><td> <SELECT NAME="department" > <option selected>Select Department</option> <option>Advanced Hosting Support</option> <option>Server Support</option> <option>Managed Support</option> <option>All</option> </SELECT> </td></tr> </tr> </tr> </table> <br><br> <input type="submit" value="submit" /> </form> <form action="" method="post"> </form> </html> <?php require_once('global.inc.php'); class DataLogic { //function to obtain Employee names from RealID array to pass to MSSQL for call count function GetEmpNames ($RealID) { global $ems_db_connect; foreach ($RealID as $emplist){ $query1 = mysql_query ("SELECT FirstName, LastName FROM ems_employee_list WHERE RealID=$emplist", $ems_db_connect) or die(mysql_error());; while($row = mysql_fetch_array($query1)) { $FirstName[] = $row['FirstName']; $LastName[] = $row['LastName']; } } $friendlyname = array('first_name' => $FirstName, 'last_name' =>$LastName); return $friendlyname; } //function to display Employee names from RealID array obtained from department and shift function DisplayEmpNames ($RealID) { global $ems_db_connect; foreach ($RealID as $emplist){ $query1 = mysql_query ("SELECT FirstName, LastName FROM ems_employee_list WHERE RealID=$emplist", $ems_db_connect) or die(mysql_error());; while($row = mysql_fetch_array($query1)) { $FirstName = $row['FirstName']; $LastName = $row['LastName']; $fullname[] = "$LastName, $FirstName"; } } return $fullname; } //function to pull the RealID's of Employees based on shift //Returns a list of RealID's for use with GetIris and RepSort functions function SelectEmpShift ($key) { global $ems_db_connect; switch($key) { case "First": $shift = 1; break; case "Second": $shift = 2; break; case "Third": $shift = 3; break; default: $shift = 4; } if ($shift == 4){ $query1 = mysql_query ("SELECT RealID FROM ems_employee_list LEFT JOIN ems_employee_schedules USING (EmployeeID) WHERE RealID > 0 AND Department='AHS'", $ems_db_connect) or die(mysql_error()); while ($row = mysql_fetch_array($query1)) { $x[]=$row['RealID']; } } else { $query1 = mysql_query ("SELECT RealID FROM ems_employee_list LEFT JOIN ems_employee_schedules USING (EmployeeID) WHERE RealID > 0 AND Shift = $shift AND Department ='AHS'", $ems_db_connect); while ($row = mysql_fetch_array($query1)) { $x[]=$row['RealID']; } } return $x; } //Function to Select Employees based on Department function SelectEmpDep ($key) { global $ems_db_connect; switch($key) { case "Managed Support": $deptcode = 6; break; case "Server Support": $deptcode = 5; break; case "Advanced Hosting Support": $deptcode = 2; break; default: $deptcode = 7; } if ($deptcode == 7){ $query1 = mysql_query ("SELECT RealID FROM ems_employee_list LEFT JOIN ems_employee_schedules USING (EmployeeID) WHERE RealID > 0 AND Department='AHS'", $ems_db_connect) or die(mysql_error()); while ($row = mysql_fetch_array($query1)) { $x[]=$row['RealID']; } } elseif ($deptcode == 5){ $query1 = mysql_query ("SELECT RealID FROM ems_employee_list LEFT JOIN ems_employee_schedules USING (EmployeeID) WHERE RealID > 0 AND AccessID=5 OR AccessID=3 AND Department='AHS' AND RealID >0", $ems_db_connect) or die(mysql_error()); while ($row = mysql_fetch_array($query1)) { $x[]=$row['RealID']; } } else { $query1 = mysql_query ("SELECT RealID FROM ems_employee_list LEFT JOIN ems_employee_schedules USING (EmployeeID) WHERE RealID > 0 AND AccessID=$deptcode AND Department ='AHS' ", $ems_db_connect); while ($row = mysql_fetch_array($query1)) { $x[]=$row['RealID']; } } return $x; } //function to sort Shift by multiple Deparments function RepSortShiftDept ($RealIDShift, $RealIDDepartment='', $RealIDDepartment2='') { $deptnumber = func_num_args(); if ($deptnumber == 1) { $result = $RealIDShift; } elseif ($deptnumber == 2) { $result = array_intersect($RealIDShift, $RealIDDepartment); } else { $result = array_intersect($RealIDShift, array_merge($RealIDDepartment, $RealIDDepartment2)); } return $result; } //function to sort Department by multiple Shifts function RepSortDeptShift ($RealIDDepartment, $RealIDShift='', $RealIDShift2='') { $shiftnumber = func_num_args(); if ($shiftnumber == 1) { $result = $RealIDDepartment; } elseif ($shiftnumber == 2) { $result = array_intersect($RealIDDepartment, $RealIDShift); } else { $result = array_intersect($RealIDDepartment, array_merge($RealIDShift, $RealIDShift2)); } return $result; } //Function to get and display count of Iris tickets from a date rage. //$RealID needs to be an array of EmployeeIDs obtained from SelectEmpShift, SelectEmpDepart, and RepSort functions function GetIris($RealID, $startdate, $enddate) { global $hocstat_db_connect; foreach ($RealID as $emplist){ $mssqlquery = "SELECT COUNT (IncidentID) AS mycount FROM hocstats.dbo.DailyStatsEmployee WHERE hocstats.dbo.DailyStatsEmployee.EmployeeID=$emplist AND(hocstats.dbo.DailyStatsEmployee.DateModified BETWEEN '$startdate 00:00:00.000' AND '$enddate 23:59:59.000')"; $query_3 = mssql_query ($mssqlquery, $hocstat_db_connect); $row =(mssql_fetch_array($query_3)) ; $iriscount[] = $row['mycount']; } return $iriscount; } //Function to get and display call counts from a date range. For use with GetEmpName ONLY function GetCalls ($friendlyname, $startdate, $enddate) { global $hocstat_db_connect; for ($x = 0; $x < count ($friendlyname['last_name']); $x++) { $query1 ="SELECT ISNULL(SUM(CallsHandledToHalf), 0) AS calls FROM Agent_Skill_Group_Half_Hour ASGHH WITH (NOLOCK) INNER JOIN dbo.agent ON ASGHH.skilltargetid = dbo.agent.skilltargetid WHERE(dbo.agent.enterprisename = 'HOC_{$friendlyname['last_name'][$x]}_{$friendlyname['first_name'][$x]}' OR dbo.agent.enterprisename = '{$friendlyname['last_name'][$x]}_{$friendlyname['first_name'][$x]}') AND (ASGHH.datetime BETWEEN '$startdate 00:00:00' AND '$enddate 23:59:00')"; $mssqlquery = mssql_query ($query1, $hocstat_db_connect); while ($row =(mssql_fetch_array($mssqlquery))) { $callcount[] = $row['calls']; } } return $callcount; } }//class close if($_POST) //setting varibles from form input { $shift_id= isset($_POST['shift']) ? trim($_POST['shift']) : die('Missing entry: Shift Selection'); $start_date= isset($_POST['startdate']) ? trim($_POST['startdate']) : die('Missing enty: Start Date'); $end_date= isset($_POST['enddate']) ? trim($_POST['enddate']) : die('Missing enty: End Date'); $depart_id= isset($_POST['department']) ? trim($_POST['department']) : die('Missing entry: Shift Selection'); } echo "You have selected stats for $shift_id shift(s) and $depart_id department(s) from $start_date to $end_date. </br>" ; $test=new DataLogic(); $calls = $test->GetCalls($test->GetEmpNames($test->RepSortShiftDept($test->SelectEmpShift("$shift_id"), $test->SelectEmpDep("$depart_id"))), $start_date, $end_date); $iris= $test->GetIris ($test->RepSortShiftDept($test->SelectEmpShift("$shift_id"), $test->SelectEmpDep("$depart_id")), $start_date, $end_date); $name= $test-> DisplayEmpNames($test->RepSortShiftDept($test->SelectEmpShift("$shift_id"), $test->SelectEmpDep("$depart_id"))); $table = array ( 'calls' => $calls, 'iris' => $iris, 'name' => $name); for ($x = 0; $x < count ($table['calls']); $x++) { echo $table["name"][$x]; echo "</br> Calls Taken :"; echo $table["calls"][$x]; echo "</br> Iris Tickets Resolved:"; echo $table["iris"][$x]; echo "</br>"; } ?> Hi My code was working perfectly when my hosting company located in Japan. But i transfer to US(hostgator) and now my time zone changes asia/tokyo to America/Chicago. Therefore, all my codes, scripts and sites are following one day behind of Japan local time. Great appreciate for any help. My code is below: <?php $host = "localhost"; $user = "user"; $pass = "pass"; $data = "mysql_db"; $cn = mysql_connect($host, $user, $pass) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($data, $cn) or die("Could not Connect Database Please Try again later !!!"); mysql_query("set names utf-8", $cn); if(date("H:i:s") < '03:00:00') // Changes midnight 00:00:00 to 03:00:00 $midnight = 1; else $midnight = 0; $TODAY__ = mktime(0, 0, 0, date("n"), date("d") - $midnight, date("Y")); date_default_timezone_set('Asia/Tokyo'); ?> Hi guys i am facing a problem in my php code and i dont know how to figure out so i search on google and i have started searching for a php forums and i found this community. The problem is i made three pages in page1 i create a simple form with one text field and add two buttons one name is "add more fields" and one is "submit" when i click on add more fields button a text field is generate by using javascript functions. Let say i create 3 fields and enter names and submit the form by having form action "page2" In page2 i just simply get all values i entered in fields and print them on screen and also there is a link of "page3" that says edit your information and the session is start. In "page3" i made changes to values and submit them again again. Its all working. But i i also want "add more fields" button in page3 so that i can generate more fields also on page3 and this this the point where i stucked and i didn't figure out how can i do this task to create add more fields button. Can you guys help me in this regard thanks. Page1 Code: Code: [Select] <!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> <script> function addonemore() { var tot = document.getElementById('count').value; tot = parseInt(tot)+1; document.getElementById('count').value=tot; var newhtml = 'student '+tot+' <input type="text" name="val'+tot+'" id="val'+tot+'" /><br/>'; document.getElementById('mydiv').innerHTML += newhtml; } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="page2.php" method="post" enctype="application/x-www-form-urlencoded"> student 1 <input type="text" name="val1" id="val1" /> <div id="mydiv"></div> <input type="button" id="addnew" name="addnew" value="Add more" onclick="addonemore()" /> <input type="submit" id="submit" name="submit" value="submit" /> <input type="hidden" name="count" id="count" value="1" /> </form> </body> </html> Page2 Code: Code: [Select] <?php session_start(); $_SESSION['count'] = $_REQUEST['count']; for($i=1;$i<=($_REQUEST['count']);$i++) { $html .= 'student '.$i.':'.$_REQUEST['val'.$i].'<br/>'; $_SESSION['val'.$i] = $_REQUEST['val'.$i]; } echo $html; echo "<br/><a href='page3.php'>click here to edit</a>"; ?> Page3 Code: Code: [Select] <html> <head> <script> function addonemore() { var tot = document.getElementById('count').value; tot = parseInt(tot)+1; document.getElementById('count').value=tot; var newhtml = 'student '+tot+' <input type="text" name="val'+tot+'" id="val'+tot+'" /><br/>'; document.getElementById('mydiv').innerHTML += newhtml; } </script> </head> <body> <?php session_start(); $html = '<form action="page2.php" method="post" enctype="application/x-www-form-urlencoded">'; for($i=1;$i<=($_SESSION['count']);$i++) { $html .= 'student '.$i.':<input type="text" name="val'.$i.'" id="val'.$i.'" value="'.$_SESSION['val'.$i].'" />'; } $html .='<input type="submit" id="submit" name="submit" value="submit" /><input type="hidden" name="count" id="count" value="'.$_SESSION['count'].'" /></form>'; echo $html; ?> <?php $html = '<form action="" method="post" enctype="application/x-www-form-urlencoded">'; $html .= '<input type="button" id="addnew" name="addnew" value="Add more" onclick="addonemore()" /></form>' ?> </body> </html> |