PHP - Call-time Pass-by-reference Problem
Hello all I just got some errors in my script
This is it: Deprecated: Call-time pass-by-reference has been deprecated in cls_xml.php on line 61 Deprecated: Call-time pass-by-reference has been deprecated in cls_xml.php on line 164 Deprecated: Call-time pass-by-reference has been deprecated in cls_xml.php on line 316 This is my script lines 61 : xml_set_object($this->parser, &$this); 164: array_push($toreturn, &$this->ownerDocument->nodes[$i]); 316: $text=trim(&$this->ownerDocument->nodes[$j]->text); What can be the problem for this error.What can cause it. thank you in advance for your help Similar TutorialsSo does it mean that you cannot call variables by reference in newer version of php? Why is it deprecated? Is it abad thing or what? Any help is appreciated. Hello, I was trying out some code to check out how some of the php settings work and when i tried allow_call_time_pass_reference to see if it works, it doesn't spew out any warning or error like the comments in the .ini file mention (or in the manual sites). Maybe i'm not using some other setting in order to see this? Here is my EXACT code. <?php ini_set('display_errors',1); error_reporting(-1); $variable = 'String'; function display($variable) { return $variable; } echo display(&$variable); ?> Outputs : String. No errors, no warnings. I'm running PHP Version 5.3.2-1ubuntu4.5 Hi Guys Probably a simple answer to this. Writing a script where I have a foreach to escape data in a multi dimensionsal array - destined for the database. I want to preserve the the escaped values in the array so I've passed in the value by referece. See code below: Code: [Select] foreach($myarray as $key=>$value){ foreach($value as $k=>$v){ $v = $mysqli->real_escape_string(&$v); echo $v ."<br/>"; } } I've switched on error_reporting(E_STRICT), because i read it was good practice to build your scripts with this on. Anyway - when i pass by reference I get a message as follows: Quote Deprecated: Call-time pass-by-reference has been deprecated in C:\wamp\www\wh\C.php on line 105 So if pass by reference is deprecated, what's the alternative? I realise i could pass the new values to a new array. But does this mean i shouldn't pass by reference anymore? Many thanks and sorry for going round the planet to ask such a simple question. Drongo hello how do i pass a foreach loop through "Passing by Reference" say i have a foreach loop in a function like this: Code: [Select] function findText(&$output){ $word = Text::find_all(); foreach ($word as $words){ $output = $words->text; } } then one the page i put Code: [Select] findText($output); echo $output; that will just give me the last word in the database. so how do i get it to echo out the array on the page ? thanks I work with a large codebase and I have this situation come up fairly often:
the legacy class has large objects such as:
$design->motor->dimensions->a; $design->motor->dimensions->bd; $design->specifications->weight; $design->data->height; //etcWhen I create a new class, that class sometimes operates on the specific data, so say: class MyClass { public function compute($weight, $height, $a) { //stuff } } //and I call this for example as such: (new MyClass())->compute($design->specifications->weight, $design->data->height, $design->motor->dimensions->a);CONS: Potential issue: if design specs change and I need to change things parameters in "compute" function, I need to "re-key" the variables I pass to the function, and adjust things accordinly in MyClass as wel. PROS: only the exact data is being passed, and this data can come from anywhere it is viable, so in effect the function is fairly well separated, I think. Alternative option for me is to pass the entire design object, i.e class MyClass { public function compute(&$design) //can also be done via DI through a setter or constructor. { print $design->specifications->weight; print ($design->data->height + $design->motor->dimensions->a); //stuff } } (new MyClass())->compute($design);PROS: In this case when things change internally in which variables are needed and how things are computed, I only need to change the code in compute function of the class itself. CONS: MyClass now needs to be aware of how $design object is constructed. When it comes to this parameter passing, and Dependency Injection like this in general, does Computer Science advocate a preference on this issue? Do I pass the entire object, or do I pass only the bits and pieces I need? I'm trying to get a simple table to display and am not sure how to make it happen. Table will have just 2 columns. A TIME and an EVENT. What I want to have happen is for the first row to show the TIME and next to that, the EVENT. If a TIME has more than one event going I want the next row to show an empty first cell and then the second event below the first. If I set up the loop the only way I know how (so far) it would also output the TIME value again and again as many times as there were events for that same time. For example what I don't want is: 9:15 Sunday School 9:15 Nursery Available What I do want is: 9:15 Sunday School Nursery Available Thanks. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 OVERVIEW: The code is about making call to the escreen web service using SOAP and Curl with client authentication required. Currently I am not getting any result only HTTP 403 and 500 errors. The call requires client authenticate cert to be on the callng site. CODE: $content = "<TicketRequest> <Version>1.0</Version> <Mode>Test</Mode> <CommitAction></CommitAction> <PartnerInfo> <UserName>xxxxxxxxxx</UserName> <Password>xxxxxxxxxxx</Password> </ PartnerInfo> <RequestorOrderID></RequestorOrderID> <CustomerIdentification> <IPAddress></IPAddress> <ClientAccount>xxxxxxxxxx</ClientAccount> <ClientSubAccount>xxxxxxxxxx</ClientSubAccount> <InternalAccount></InternalAccount> <ElectronicClientID></ElectronicClientID> </CustomerIdentification> <TicketAction> <Type></Type> <Params> <Param> <ID>4646</ID> <Value></Value> </Param> </Params> </TicketAction> </TicketRequest>"; $wsdl = "https://services.escreen.com/SingleSignOnStage/SingleSignOn.asmx"; $headers = array( "Content-type: text/xml;charset=\"utf-8\"", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", // "SOAPAction: \"\"", "Content-length: ".strlen($content), ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $wsdl); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_VERBOSE, '1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $content); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //curl_setopt($ch, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); curl_setopt($ch, CURLOPT_CAPATH, '/home/pps/'); curl_setopt($ch, CURLOPT_CAINFO, '/home/pps/authority.pem'); curl_setopt($ch, CURLOPT_SSLCERT, 'PROTPLUSSOL_SSO.pem'); curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'xxxxxxxxxxxx'); $output = curl_exec($ch); // Check if any error occured if(curl_errno($ch)) { echo 'Error no : '.curl_errno($ch).' Curl error: ' . curl_error($ch); } print_r($output); QUESTIONS: 1. I need to call the RequestTicket method and pass the XML string to it. I don't know how to do it here(pass the method name to call). 2. For client authentication they gave us three certs, one root cert, one intermediate cert and a client authentication cert PROTPLUSSOL_SSOpem(it was a .pfx file). Since we are on linux we converted them to pem . In curl calls I could not find way to how to include both the root cert and the intermediate cert ,so I combined them by making a new pem file and copying the intermediate cert and them the root cert and naming it authority.pem . I am not sure whether it works or not and would like your opinion. 3. For the current code Iam getting the error Error no : 77 Curl error: error setting certificate verify locations: CAfile: /home/pps/authority.pem CApath: /home/pps/ If I disable the curl error message,I am getting blank page with page title 403 - Forbidden. Access is denied. If I comment out the CURLOPT_CAPATH and CURLOPT_CAINFO lines it gives http 500 error page with the message as content and the following at the top. > HTTP/1.1 500 Internal Server Error. Cache-Control: private Content-Type: text/html Server: Microsoft-IIS/7.5 X-AspNet-Version: 1.1.4322 X-Powered-By: ASP.NET Date: Thu, 02 Sep 2010 14:46:38 GMT Content-Length: 1208 If I comment out as above and also CURLOPT_SSLCERT and CURLOPT_SSLCERTPASSWD it gives 403 error with the message as content. So I would request you to help me out by pointing out whats wrong with the current code. Thank you. I can call the following function successfully as a single php program // Acknowledge and clear the orders function ack($client, $merchant, $id) { $docs = array('string' => $id); $params = array('merchant' => $merchant, 'documentIdentifierArray' => $docs); $result = $client->call('postDocumentDownloadAck', $params); return $result; } with $result = ack($t, $merchant,'2779540483'); successful output [documentDownloadAckProcessingStatus] => _SUCCESSFUL_ [documentID] => 2779540483 I'm trying to figure out how to call this function as an object from another program. Trying the following gives error ***Call to a member function call() on a non-object*** function postDocumentDownloadAck($t, $merchant, $id) { $this->error = null; $docs = array('string' => $this->id); $params = array('merchant' => $this->merchant, 'documentIdentifierArray' => $docs); ** I've tried the following which does nothing $result = $this->soap->call('postDocumentDownloadAck', $params); ** I've tried the following - which gives error "Call to a member function call() on a non-object" $result = $this->t->soap->call('postDocumentDownloadAck', $params); if($this->soap->fault) { $this->error = $result; return false; } return $result; } *** calling program snippet for above function $merchant= array( "merchant"=> $merchantid, "merchantName" => $merchantname, "email"=> $login, "password"=> $password); $t = new AmazonMerchantAPI($merchantid, $merchantname, $login, $password); $documentlist= $t->GetAllPendingDocumentInfo('_GET_ORDERS_DATA_'); $docid = $documentlist['MerchantDocumentInfo'][$i]['documentID']; $docs = array('string' => $docid); $ackorders = $t->postDocumentDownloadAck($t, $merchant,$docs); Any ideas of what I'm doing wrong are greatly appreciated. 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'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 ()" 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. 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'); ?> Ok first of all I want to apologize for asking what I'm about to ask. I understand it should be some stupidly easy to find mistake but considering the fact I have to send the code tomorrow leaves me with little to no time to try and find the solution so I'll be asking here and hope that by the time I wake up tomorrow an answer will be here and I'll be able to resume scripting. So my problem is that I just can't find how to make php commands run at all. I tried just randomly inserting them into my html code then found out it needs a separate file. So I created the basic.php with this code: <html> <body> <?php echo "Hello World"; ?> <div>adgaeganerhaohn</div> </body> </html> tried opening it through a form in my html code but it wouldn't print the Hello world line, then I tried running it straight into firefox but I only got adgaeganerhaohn again (without that line I get a white page) So I need to know what am I doing wrong? I have php5.301 installed with default options (no server). thanks for your help beforehand, once I get a bit more into php I'll be coming back with serious questions but for now I really need someone to tell me how php is supposed to work and what I'm doing wrong 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> 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> Hi all. What am I doing wrong here? I cannot read from the file with fopen, this is the code. <html> <body> <?php $file=fopen("welcome.txt","r"); ?> </body> </html> I get a blank page, although I have text written in that file. Whenever I set it to "w" it still shows nothing - when I check the file manually with notepad, I see that it's blanked - but I think thats meant to happen, after all "w" clears the file. Have I understood correctly? This still shows a blank page, but it says it can't find the file if it's not in the directory - how it should be. <html> <body> <?php $file=fopen("welcome2123.txt","r") or exit("Unable to open file!"); ?> </body> </html> tl;dr - Why doesn't fopen read anything from the txt file? Encodings match - everything is in UTF-8, although I doubt thats the problem... Help? |