PHP - Php, Variables, Oop, Etc... (i Don't Know What To Call This, But I Need Help)
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. Similar TutorialsHello, my global variable is getting whacked (defined null or being undefined) after a function call. I'm not sure if it's happening when leaving the function that assigns it or when the form is "posted", or something else. Code: [Select] <? //global variables $globalVarString = ""; //function definitions function displayResults() { global $globalVarString; if ($globalVarString == "") {displayForm("please enter your search string again");} else {displayForm("you typed: $globalVarString");} } function getResults($searchInput) { global $globalVarString; $globalVarString = $searchInput; //give status ?> <html><head><title>Search</title></head><body> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> Thanks for entering your data (<? echo "$globalVarString" ?>).<br><br>Please press the submit button to process your data    <input type="Submit" value="Submit" name="processQuery"> </form></body></html> <? } function displayForm($message) { //prompt for input ?> <html><head><title>Search</title></head><body> <form action=" <? $_SERVER['PHP_SELF'] ?>" method="post"> <h3>Please enter your search <input type="text" name="searchString">    <script type="text/javascript">document.forms[0].searchString.focus();</script> <input type="Submit" value="Submit Query" name="searchQuery"></h3> </form> <? if (!$message == ""){echo "<br>    <h4>" . $message . "</h4><br>";} ?> </body></html> <? } //main() if(array_key_exists('searchQuery', $_POST)) {getResults($_POST['searchString']);} elseif (array_key_exists('processQuery', $_POST)) {displayResults();} else {displayForm("");} ?> 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. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 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 does anyone know how to decode this XML variable value into string values? I also need to know the oposite way: creating variable values into xml. I've tried several code examples but they did filter the requested data. Code: [Select] $xml='<?xml version="1.0" encoding="utf-8"?> <elements> <text identifier="ed9cdd4c-ae8b-4ecb-bca7-e12a5153bc02"> <value/> </text> <textarea identifier="a77f06fc-1561-453c-a429-8dd05cdc29f5"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <textarea identifier="1a85a7a6-2aba-4480-925b-6b97d311ee6c"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <image identifier="ffcc1c50-8dbd-4115-b463-b43bdcd44a57"> <file><![CDATA[images/stories/red/cars/autobedrijf.png]]></file> <title/> <link/> <target/> <rel/> <lightbox_image/> <width><![CDATA[250]]></width> <height><![CDATA[187]]></height> </image> <text identifier="4339a108-f907-4661-9aab-d6f3f00e736e"> <value><![CDATA[Kramer 5]]></value> </text> <text identifier="ea0666d7-51e3-4e52-8617-25e3ad61f8b8"> <value><![CDATA[6000 RS]]></value> </text> <text identifier="90a18889-884b-4d53-a302-4e6e4595efa0"> <value><![CDATA[Eindhoven]]></value> </text> <text identifier="410d72e0-29b3-4a92-b7d7-f01e828b1586"> <value><![CDATA[APK Pick up and return]]></value> </text> <text identifier="45b86f23-e656-4a81-bb8f-84e5ea76f71f"> <value><![CDATA[15% korting op grote beurt]]></value> </text> <text identifier="3dbbe1c6-15d6-4375-9f2f-f0e7287e29f3"> <value><![CDATA[Gratis opslag zomerbanden]]></value> </text> <text identifier="2e878db0-605d-4d58-9806-8e75bced67a4"> <value><![CDATA[Gratis abonnement of grote beurt]]></value> </text> <text identifier="94e3e08f-e008-487b-9cbd-25d108a9705e"> <value/> </text> <text identifier="73e74b73-f509-4de7-91cf-e919d14bdb0b"> <value/> </text> <text identifier="b870164b-fe78-45b0-b840-8ebceb9b9cb6"> <value><![CDATA[040 123 45 67]]></value> </text> <text identifier="8a91aab2-7862-4a04-bd28-07f1ff4acce5"> <value/> </text> <email identifier="3f15b5e4-0dea-4114-a870-1106b85248de"> <value/> <text/> <subject/> <body/> </email> <link identifier="0b3d983e-b2fa-4728-afa0-a0b640fa34dc"> <value/> <text/> <target/> <custom_title/> <rel/> </link> <relateditems identifier="7056f1d2-5253-40b6-8efd-d289b10a8c69"/> <rating identifier="cf6dd846-5774-47aa-8ca7-c1623c06e130"> <votes><![CDATA[1]]></votes> <value><![CDATA[1.0000]]></value> </rating> <googlemaps identifier="160bd40a-3e0e-48de-b6cd-56cdcc9db892"> <location><![CDATA[50.895711,5.955427]]></location> </googlemaps> </elements>'; Hi. I have some code which needs to return a single variable from the function and stored as a variable within this page, so it can be echoed later on in the page. I couldn't get it to return as a variable, so i used "return compact();" to return the variable and "extract (myFunction());" to extract it to variables. However, when I turned on php's display errors and error reporting function, I got an error message saying "Warning: extract() [function.extract]: First argument should be an array in /my/web/site/index.php on line 6" (which is where my extract function is). This works fine with passing more than one variables through, is there another way pass one variable from a function to be stored as a variable on the page which called the function? Here is the function: Code: [Select] <?php //This is a list of numeric error codes against their text. this will return the error code as the variable $issue function checkLoginIssue() { //If there is an error code if (isset($_GET["issue"])) { //cycle through the list until the code is reached, return the text and break the switch switch ($_GET["issue"]) { case "1": $issue = '<p class="warning">Please log in to view this page</p>'; break; case "2": $issue = '<p class="warning">Wrong Username or Password</p>'; break; case "3": $issue = '<p class="warning">No user found with those details</p>'; break; } //return the variable in an array with a single value return compact('issue'); } } ?> And here is the code which calls the function: Code: [Select] <?php extract(checkLoginIssue()); ?> 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. 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! 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. 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 "....."; $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 Hello, I was wondering how I can call another web page. I don't want to read the page I just need to send it information like test.php?action=this I don't need to read or store I just need to pass it info so it can handle some site changes on the other site. Thanks in advance! 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. Hi guys I AM NEW TO PHP AND MYSQLI... TRYING TO CALL FUNCTION BUT I GOT ERROR CANT FIGURE OUT WITH IT IS, THANKS FOR HELP ME functions.php
<?php
echo mysqli_error($db);
<?php
<?php ERROR Parse error: syntax error, unexpected ';', expecting '{' in C:\wamp64\www\gloria-blog\index.php on line 9
THANKS
Hi im new to php Im excellent in C# more but lets not go into that I was wondering how to call this function. What am i doing wrong.. <?php if(isset($_POST['submit'])) { $startDate = strtotime($_POST['startdate']); $endDate = strtotime($_POST['enddate']); if($startDate != false && $endDate != false) { $startDate = date("y-m-d",$startDate); $endDate = date('y-m-d',$endDate); SearchForBookedRooms($startDate,$endDate); } else { echo "Please select both dates!"; } function SearchForBookedRooms($startDate,$endDate)//Calling this Function Here?? { } } ?> 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 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 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? |