PHP - Osirix Xmlrpc Call
Greetings,
I have a project to integrate Osirix viewer with an existing application. This is beyond my comfort level in so far as I have never used XMLRPC before. I am looking for an example of a web browser making an XMLRPC call to http://localhost:8080with the following XML: <?xml version="1.0"?> <methodCall> <methodName>Close2DViewerWithStudyUID</methodName> <params> <param> <value><struct> <member> <name>uid</name> <value><string>1.2.840.113745.101000.1008000.37915.4331.5559218</string></val ue> </member> </struct></value> </param> </params> </methodCall> I also need to get the response back to make sure the call succeeded. If anyone has any help, it would be appreciated. Thankyou! Rab Similar TutorialsThe array. Output of the variable $v Code: [Select] xmlrpcval Object ( [me] => Array ( [struct] => Array ( [sec] => xmlrpcval Object ( [me] => Array ( [string] => 349955dd5d3156af95cb4e75a13cffaa ) [mytype] => 1 ) ) ) examples of what I have tried echo $v->string; How could I get the value of [string]. I know that its an object but cannot find how to get the value. Hows it going guys. Well, I'm trying to create an app tat deals with the barracuda API. Unfortunately it uses all XML for its methods, so I had to come up with this: Code: [Select] <?php include ("xmlrpc.inc"); $y = new xmlrpcval ( array ("child_type" => new xmlrpcval("domain", "string"), "path" => new xmlrpcval("", "string"),"type" => new xmlrpcval("global", "string")) , "struct"); $m = new xmlrpcmsg ('config.list'); $m ->addParam($y); $c= new xmlrpc_client("http://barracudaaddress/cgi-mod/index.cgi?password=mypassword"); $c->setDebug(2); $r = $c ->send($m); if (!$r->faultcode()) { $v= $r->value(); print $r->serialize(); } else { print "Fault <br/>"; print "Code: ". htmlentities($r->faultcode()) . "<br/>" . "reason: '" . htmlentities($r->faultString()) . "'<br/>"; } ?> the problem is that when I run this, i get the following error: Code: [Select] XML error: XML_ERR_NAME_REQUIRED at line 2, column 61Fault Code: 2 reason: 'Invalid return payload: enable debugging to examine incoming payload (XML error: XML_ERR_NAME_REQUIRED at line 2, column 61)' but when i look at my php code, line 2 is technically: Code: [Select] include ("xmlrpc.inc"); Does this mean my error is coming from that file? Because as far as I can tell, the XML output is working well, since this is what is getting sent to the server: Code: [Select] <?xml version="1.0"?> <methodCall> <methodName>config.list</methodName> <params> <param> <value><struct> <member><name>child_type</name> <value><string>domain</string></value> </member> <member><name>path</name> <value><string></string></value> </member> <member><name>type</name> <value><string>global</string></value> </member> </struct></value> </param> </params> </methodCall> Which is what is required for this method. I've racked my brain and can't figure it out, any help would be appreciated. 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. Hello, I've been trying this for hours now, looking at different examples and trying to change them to work for me, but with no luck... This is what I am trying to do: I have a simple form with: - 1 input field, where I can enter a number - 1 Submit Button When I enter a number into the field and click submit, I want that number to be send to the php file that is in the ajax call, then the script will take that number and run a bunch of queries and then return a new number. I want that new number to be used to call the php script via ajax again, until no number is returned, or something else is returned like the word "done" or something like that, at which point is simply makes an alert or populated a div with a message... The point is, that depending on the number entered it could take up to an hour to complete ALL the queries, so I want the script that is called to only run a fixed amount of queries at a time and then return the number it is currently at (+1), so that it can continue with the next number when it is called again. I would like to use jquery, but could also be any other way, as long as I get this to work. I already have the php script completed that needs to be called by the ajax, it returns a single number when being called. Thank you, vb Trying to hook up to an API using php. The API commands are sent in url query strings. Depending on the command you are sending in the query string, the API returns an XML file or text. For commands that return an XML file I can use $response=simplexml_load_file($APIcall) and parse and store the xml that comes back into $response. But with text responses from the API I cannot find a way to handle the reply. Using xml_load_file() results in errors displayed since it was expecting xml and nothing gets stored in $response, although the command is correctly executed by the API. I can use headers('Location: $APIcall') but that just gets the text response sent to a new window. $response=get_headers($APIcall) works for some commands but still does not capture the text response. Hi,
I'm trying to combine the two codes below so that my images can be styled by CSS?
echo '<img src="' . get_stylesheet_directory_uri() . '/images/category-two.png' . '" alt="Your Alt Text" />'; array( 'class' => 'alignleft' )Thanks for your time. I have created a form and the .php file that collects the selected data. What I cannot seem to find out is the code to put into the process.php to retrieve information from my sql db that a crawler retrieved.
Form
<form action="process.php" method="post"> Game: <select name="game"> <option>Select a Game</option> <option>Counter-Strike 1.3</option> <option>Counter-Strike: Source</option> <option>Counter-Strike: GO</option> <option>ArmA: 3</option> <option>Call Of Duty: 4</option> </select> Slots <select name="game"> <option>Desired Slots</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> </select> <input type="submit" /> </form>Process.php <?php $quantity = $_POST['quantity']; $item = $_POST['item']; echo "You are looking for a ". $game . " server with " . $slots . " slots.<br />"; echo "We are processing your request!"; ?>I am looking for it to be out putted into a nice table as such <TR> <TH><font color="red"><b>Company</B></font></TH> <TH><font color="red"><b>Slots</B></font></TH> <TH><font color="red"><b>Pricing</B></font></TH> </TR> <TR ALIGN="CENTER"> <TD>$company</TD> <TD>$slots</TD> <TD>$price</TD> </TR>Thanks for your assistance! Please help me in this guys....... I am using MVC model for my application . I am stuck with the ajax call. this is my controller application/controller/admin/index.php function getCity() { $city=$this->model->getCity(); foreach($this->city as $key => $value) { echo '<option>'.$value['name'].'</option>' ; } } this is my model application/model/admin_model.php public function getCity() { if($_POST['id']) { $cid=$_POST['id']; $sth = $this->db->prepare('SELECT id, name FROM unit WHERE cid= :cid'); $sth->execute(array(':cid' => $cid)); return $sth->fetchAll(); } } this is my view <form id="city" action="<../application/admin/regstr/" method="post"> Country <select name="country" class="country"> <option value="" selected="selected">--Select Taluka--</option> <option value="1">India</option> <option value="2">USA</option> <option value="3">China</option> </select> City <select name="city" class="city"> <option selected="selected">--Select City--</option> </select> <input type="submit" /> </form> and this is my javascript for Ajax $(document).ready(function() { $(".country").change(function() { var id=$(this).val(); var dataString = 'id='+ id; $.ajax ({ type: "POST", url: "admin/getCity", data: dataString, cache: false, success: function(html) { $(".city").html(html); } }); }); }); But I am not getting the output. I have tested it with firebug in response tab. Instead of getting only option values html code as output I am getting the whole HTML page content (i.e. content of view page admin/index.php. Please help me out. Is this even possible? I'm trying to call function nameGen from in the function nameGen but I just get an error saying cannot redeclare. I only want it to return $newName when it is not in the array $takenVals. can this only be done with another loop and a constant somewhere? Code: [Select] $newVarVals = array(); $takenVals = array(); $varCount = count($varArray); // contents are set else where and is fine for($i = 0 ; $i < $varCount; ++ $i) { function nameGen(&$varCount,&$takenVals){ $newName = rand(0,$varCount); if(in_array($newName,$takenVals)) { nameGen(&$varCount,&$takenVals); } else{ return $newName; } } $newName = nameGen(&$varCount,&$takenVals); $takenVals[] = $newName; $newNameToKeep = '$_'.$newName; $newVarVals[] = array('oldName' => $varArray[$i], 'newName' => $newNameToKeep); } error: Cannot redeclare nameGen() hi I have a problem with my code. Actually i want to make a dynamic page. for that i have a database from where i get data. I getting data dynamically at homepage & make a hyperlink there with html code. But in actual inner pages are not exists. I made a file there which is getting dynamic data also. All comparing data is put in redirect.html on server & also include that specific file as well................Main Problem is that i do not know from where to call redirect.php....because when a link is clicked server open that page & we redirect control to redirec.php....... Is there any possible solutions Hi
I'm trying to get the layout like i want but it's not easy
I have this file
<?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } if(isset($_POST['submitted'])) { $fgmembersite->PesquisarPorDatas(); } ?> <div id='fg_membersite_content'> <div class="CSSTableGenerator" > //I want the result here </div> <br>I want the result of this $fgmembersite->PesquisarPorDatas(); in "//I want the result here" the r of my code, when the user use the "Pesquisar" button this fucntion is called but the result comes out of my css any help please?? Edited by alphasil, 04 December 2014 - 10:32 AM. $y is my variable that I increment by a for loop. This variable determines the number of every row ..and then i'd concat'd $y with the name of the textboxes of every column and row name="orno<?php echo $y;?>" now, i'm not sure if i'm supposed to concat with the name or should it be with the id? HOW DO i CALL THE NAME FROM ANOTHER PAGE? this is what I did and I don't know if this is right $orno= $_POST['orno'.$y]; and since I know I may not be making much sense with my explaination above, this is my add_content.php where it all starts I've only included the part where the textboxes are displayed by/within a loop and where the names are concatenated with the variable $y. I have dropdowns and textboxes for the date and other elements above this. <div id="slider"> <ul> <?php $num=$_GET['num'];//this here represents the number of rows //of textboxes user wants to appear //there are 5 textboxes in one row and 10 rows in one page //this is a sliding page with jquery $nump=$num / 10; $y=1;//initializing y for($j=1;$j<=$nump;$j++){//determines how many pages then loops accordingly ?> <li> <p> <?php for($i=1;$i<=10;$i++){//loops 10 times to return 10 rows in a pages if(strlen($y)==1){ echo "0"; } echo $y." "; ?> <input name="orno<?php echo $y;?>" id="orno" type="text" size="3" maxlength="6" onKeyPress="return isNumberKey (event)" value="<?php if (isset($_POST['orno'])) { echo htmlspecialchars($_POST['orno'], ENT_QUOTES); }?>"> <input name="billnmbr<?php echo $y;?>" id="billnmbr" type="text" size="16" maxlength="17" value="<?php if (isset($_POST['billnmbr'])) { echo htmlspecialchars($_POST['billnmbr'], ENT_QUOTES); }?>"> <input name="payor<?php echo $y;?>" id="payor" type="text" size="35" maxlength="50" value="<?php if (isset($_POST['payor'])) { echo htmlspecialchars($_POST['payor'], ENT_QUOTES); }?>"> <input name="arrastre<?php echo $y;?>" id="arrastre" type="text" size="7" maxlength="8" onKeyPress="return isMoneyKey (event)" value="<?php if (isset($_POST['arrastre'])) { echo htmlspecialchars($_POST['arrastre'], ENT_QUOTES); }?>"> <input name="wharfage<?php echo $y;?>" id="wharfage" type="text" size="7" maxlength="8" onKeyPress="return isMoneyKey (event)" value="<?php if (isset($_POST['wharfage'])) { echo htmlspecialchars($_POST['wharfage'], ENT_QUOTES); }?>"><br /> <?php $y++; }?> </p> </li> <?php $y=$y; } ?> </ul> </div> then we go to add_save.php this page is still very lacking because I don't know how to evaluate then save multiple rows yet since I've originally done a page that saves one row at a time in which the textboxes' names aren't from a loop and were not concatenated. <?php //please take a look at how I am calling the $_POSTs from the prev page //what is the right way of calling concatenated names? //or if there is a better way of calling these please let me know.. $year=$_POST['year']; $month=$_POST['month']; $day=$_POST['day']; $date=$year."-".$month."-".$day; $billnmbr=$_POST['billnmbr'.$y]; $orno= $_POST['orno'.$y]; $payor=$_POST['payor'.$y]; $arrastre=$_POST['arrastre'.$y]; $wharfage=$_POST['wharfage'.$y]; $total=$arrastre + $wharfage; $tcl=$_POST['tcl']; $preparedby=$_POST['preparedby']; $notedby=$_POST['notedby']; $addedby=$_POST['addedby']; $office=$_POST['office']; if($_POST['btnadd']){ if($billnmbr=="" or $orno=="" or $payor=="" or $arrastre=="" or $wharfage=="" or $year=="" or $month=="" or $day=="" or $tcl=="" or $preparedby=="" or $notedby=="" or $addedby=="" or $date=='2010-01-01'){ ?> <script> alert ('At least one field was left blank!'); </script> <?php } else{ $query = mysql_query("select * from `arrastre` WHERE `billnmbr`='$billnmbr'"); $count = mysql_num_rows($query); if($count==1){//existing billnmbr echo "This billnumber is already in the database."; } else{ $bll = strtoupper($billnmbr); $explode_bill=explode("-",$bll); $bill1 = 0; $bill2 = 0; $bill1 = $explode_bill[0]; $bill2 = $explode_bill[1]; if(strlen($bill2)<6 && strlen($bll)!=17){ if(strlen($bill2)==1){ $rep = "00000"; $bll = $bill1."-".$rep."".$bill2; } elseif(strlen($bill2)==2){ $rep = "0000"; $bll = $bill1."-".$rep."".$bill2; } elseif(strlen($bill2)==3){ $rep = "000"; $bll = $bill1."-".$rep."".$bill2; } elseif(strlen($bill2)==4){ $rep = "00"; $bll = $bill1."-".$rep."".$bill2; } elseif(strlen($bill2)==5){ $rep = "0"; $bll = $bill1."-".$rep."".$bill2; } } $payr = strtoupper($payor); $query="insert into `arrastre` values ('0', '$orno', '$bll','$payr', '$arrastre', '$wharfage', '$total', '$date', '$tcl', '$preparedby', '$notedby', '$addedby', '$office')"; $result=mysql_query($query); ?> <?php }}} ?> thank you very much How can I call this from within php? Code: [Select] <a href="#" onclick="return false" onmousedown="javascript:SlideBox('what10');">this has to be within this: Code: [Select] echo "....."; Hi, I was asking for help with this elsewhere, but after a week no one was able to answer my question so I thought someone here might be able to shed some light on it. My original question was: "I have an action that instantiates an object, and that object instantiates a bunch of child objects, and so on. My question is, do I only have to set set_time_limit() once in the action, in order to have that rule propagate to the execution of all of its child objects, or do I also have to set this in each of the class files that it calls? I similarly need to set ignore_user_abort() which I haven't used before, and I have the same question for that." To clear up confusion about what I was asking, I clarified this way: "That the limit applies to the "script" is the ambiguity I'm confused about. Technically, the original file is one script, so you set the timeout for that. But when it instantiates and object whose class code is coming from another file, that's a different "script", so presumably it could have its own timeout. And that's what my question is. Does the time out value you set automatically propagate to every other file that file calls on, or is it isolated to that file? If you set a time limit of 100 seconds, but instantiated an object from class code in a different file and called a long running method in it, and that file had a different time out, say of 30 seconds, the execution time of the original file would be limited to 30 seconds and not 100." In sum, do functions like ignore_user_abort() and set_time_limit() automatically apply to all code in the files a particular "script" require_once()'s? Or would it have to be set in those files as well? I would just test myself to find out, but the method I would use to do that would be sleep() and that time isn't counted toward set_time_limit() so it won't work. Thanks very much for any clarification someone might be able to give. Hello, I am trying to understand how to post several actions and return 1 call. I am new to this so I thank you for your understanding. Here is the full story, I have the Jquery working now that 1 "onSelect" will post to 6 php files, but it takes forever for all the calls to return to the div. From my reading, I need to put the 6 php files into one php file, and then return this with JSON... here is where my trouble begins. Now here is the current php file that I have put into 1 php file (placed as they were working when in 6 files to the Jquery below) <?php $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); $con = mysql_connect("xxxxxx","xxxxxx","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = "SELECT sum(power/1000) AS choice FROM feed WHERE date = '".$dayPower."' group by date";$res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $d = array(); while($row = mysql_fetch_assoc($res)) {; echo json_encode($d); } ?> <?php $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); $con =$con = mysql_connect("xxxxxx","xxxxxx","xxxxxx"); mysql_connect("localhost","root","mackie1604"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = " SELECT HOUR(time) as h, power FROM feed WHERE date = '".$choice."' ORDER BY HOUR(time)"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $daypower = array(); while($row = mysql_fetch_assoc($res)) { $daypower[] = $row['power']; } ?> <script type="text/javascript"> $(document).ready(function() { var chart = new Highcharts.Chart({ chart: { renderTo: 'apDiv4', defaultSeriesType: "column", }, events: { marginTop: 1, marginRight: 1, marginBottom: 1, marginLeft: 4 }, credits: { enabled: false, }, title: { text: null, }, subtitle: { text: null, }, xAxis: { labels: { y: 15 }, categories: ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'] }, yAxis: { min: 0, max: 2000, title: { text: null }, labels: { align: 'left' } }, legend: { enabled: false }, tooltip: { formatter: function() { return ''+ this.x +': '+ this.y +' Watt hr'; } }, plotOptions: { column: { pointPadding: 0.02, borderWidth: 0 } }, series: [{ name: '', color: '#50B432', data: [<?php echo join($daypower, ', '); ?>] }] }); }); </script> <?php $choice = (isset($_POST['choice'])) ? date("m",strtotime($_POST['choice'])) : date("m"); $con = mysql_connect("xxxxxx","xxxxxx","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = "SELECT sum(power/1000) AS choice FROM feed WHERE month(date) = '".$choice."'"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); echo $row['choice'].'<br />'; ?> <?php $choice = (isset($_POST['choice'])) ? date("m",strtotime($_POST['choice'])) : date("m"); $con = mysql_connect("xxxxxx","xxxxxx","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = " SELECT MONTH(date) AS m, SUM(power/1000) AS monthpower FROM feed WHERE MONTH(date) = '".$choice."' GROUP BY DAY(date) ORDER BY DAY(date)"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $monthpower = array(); while($row = mysql_fetch_assoc($res)) { $monthpower[] = $row['monthpower']; } ?> <script type="text/javascript"> $(document).ready(function() { var chart = new Highcharts.Chart({ chart: { renderTo: 'apDiv9', defaultSeriesType: "column" }, events: { marginTop: 1, marginRight: 0, marginBottom: 0, marginLeft: 1 }, title: { text: null, }, subtitle: { text: null, }, xAxis: { labels: { y: 15 }, categories: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31'] }, yAxis: { min: 0, max: 20, title: { text: null }, labels: { align: 'left' } }, legend: { enabled:false }, tooltip: { formatter: function() { return ''+ this.x +': '+ this.y +' kWh'; fontWeight: 'normal' fontSize: '1px' } }, plotOptions: { column: { pointPadding: 0.2, borderWidth: 0 } }, series: [{ name: '', color: '#50B432', data: [<?php echo join($monthpower, ', '); ?>] }], credits: { enabled:false, }, }); }); </script> <?php $choice = (isset($_POST['choice'])) ? date("Y",strtotime($_POST['choice'])) : date("Y"); $con = mysql_connect("xxxxxx","xxxxxx","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = "SELECT sum(power/1000) AS choice FROM feed WHERE year(date) = '".$choice."'"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); echo $row['choice3'].'<br />'; ?> <?php $choice = (isset($_POST['choice'])) ? date("Y",strtotime($_POST['choice'])) : date("Y"); $con = mysql_connect("xxxxxx","xxxxxx","xxxxxx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("inverters", $con); $sql = " SELECT MONTH(date) AS y, SUM(power/1000) AS yearpower FROM feed WHERE YEAR(date) = '".$choice."' GROUP BY MONTH(date) ORDER BY MONTH(date)"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $yearpower = array(); while($row = mysql_fetch_assoc($res)) { $yearpower[] = $row['yearpower']; } ?> <script type="text/javascript"> $(document).ready(function() { var chart = new Highcharts.Chart({ chart: { renderTo: 'apDiv10', defaultSeriesType: "column" }, events: { marginTop: 1, marginRight: 1, marginBottom: 1, marginLeft: 1 }, credits: { enabled: false, }, title: { text: null, }, subtitle: { text: null, }, xAxis: { labels: { y: 15 }, categories: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'] }, yAxis: { min: 0, max: 500, title: { text: null }, labels: { align: 'left' } }, legend: { enabled: false }, tooltip: { formatter: function() { return ''+ this.x +': '+ this.y +' kWh'; } }, plotOptions: { column: { pointPadding: 0.2, borderWidth: 0 } }, series: [{ name: '', color: '#50B432', data: [<?php echo join($yearpower, ', '); ?>] }] }); }); </script> Here is the Jquery that was working to send to the 6 different php files (to help you understand what my goal is... Code: [Select] $('#datepicker').datepicker({maxDate: 0, dateFormat: 'yy-mm-dd', onSelect: function(dateText) { var myDate = $(this).datepicker('getDate'); $('#apDiv1').html($.datepicker.formatDate('DD, d', myDate)); $('#apDiv5').html($.datepicker.formatDate('MM', myDate)); $('#apDiv7').html($.datepicker.formatDate('yy', myDate)); $('#apDiv2').load('dayPower.php', {choice: dateText}, function() { $(this).show(); }); $('#apDiv4').load('dayGraph.php', {choice: dateText}, function() { $(this).show(); }); $('#apDiv6').load('monthPower.php', {choice: dateText}, function() { $(this).show(); }); $('#apDiv9').load('monthGraph.php', {choice: dateText}, function() { $(this).show(); }); $('#apDiv8').load('yearPower.php', {choice: dateText}, function() { $(this).show(); }); $('#apDiv10').load('yearGraph.php', {choice: dateText}, function() { $(this).show(); }); }}); }); I am back to this as what I was changing became a mess, and I am starting from what was working.... How do I get JSON to send and return from the one PHP file. Thank You, Alan okay in modlogs.php i have a function Code: [Select] <?php function modmenu($page) { ?> <dl><dt class="<?php if ($page == 'modlogs') echo '';else echo 'ust'; ?> LEFT" style='margin-left:5px'><a href='mlogs.php'><b>User Logs</b></a> </dt><dt class="<?php if ($page == 'modlogs1') echo '';else echo 'ust'; ?> LEFT"><a href="modlogs1.php">Topic/Forum Actions</a></dt> <dd> <?php } ?> in modlogs1.php i try to echo Code: [Select] modmenu('modlogs1'); to show the menu but i get unidentified function? lol isn't functions global wtf? Hai thar all you smexy things... I has a problem, and I have come to the lovely folk here for help and/or advice... Basically when making a set of scripts I usually have some files dedicated to JUST variables (usually in the form of a associtive array) and now I feel that I don't like including EVERY variable file into my scripts because I use less than half of the files at any one time in most cases and I feel it's inefficient, so I've been trying to look into a way to call variables into a class as I need them... Basically what I've tried to do is make a class that I can call by doing something like "$_VAR->var_name['key'];" but when I use OOP5s __get method it only takes the "var_name" and leaves out the rest from what I've done, so I then tried to do something like "$_VAR->var_name('key');" and used the __call, but that didn't work out too well either, it would only return a NULL value. Here is the class I've got just now. <? class Vars{ private $var_path; function __construct($path=NULL){ if(isset($path)): $this->var_path = $path; else: $this->var_path = DOC_ROOT.'/vars'; endif; } function __call($name,$arguments){ if(isset($this->$name)): // Do nothing. elseif(is_dir($this->var_path.'/'.$name)): include $this->var_path.'/'.$name.'/'.$arguments[0].'.php'; if(isset($this->$name)): $this->{$name}[$arguments[0]] = $var; else: $this->$name = array(); $this->{$name}[$arguments[0]] = $var; endif; elseif(is_file($this->var_path.'/'.$name.'.php')): include $this->var_path.'/'.$name.'.php'; $this->$name = $var; else: //Return NULL return NULL; endif; unset($var); $return = $this->$name; for($x=0;$x<$y=count($arguments);$x++): $return = $return[$arguments[$y]]; endfor; return $return; } } ?> And this is how I would want to call the "title" feild from the layout.php file. <? $_ = new Vars('C:/xampp/htdocs/inc/vars'); echo $_->layout('title'); ?> I hope you can understand that, if not, tell me what you don't understand and I'll explain. But what I'm here for is either help to do what I'm wanting to do right now, or some advice to point me in the right direction. Thanks in advance, Alan. Hi all. Im trying to get a result on one of my pages where it says if a members is banned 1 or not 0, I cannt seem to get it to work. What i need is some code that says. get banned FROM usersgnet WHERE name = POST'name' Then print the banned i,.e 1 = YES 0 = NO Its just so i can tell if i have banned them or not. Thanks gnetuk |