PHP - Moved: Questions On Query String,service Call
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=353390.0 Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306845.0 HI, I need to know how to get the response objects from a webserve call. I call the following webservice: $params = array('mobiUser'=>"WJBASSON",'mobiPass'=>"83dop"); $soap = new SoapClient('http://172.18.22.182/csp/ampath/ReportGeneration.Mobi.Services.cls?WSDL'); $result = $soap->login($params); When I do var_dump($result) I receive the following: stdClass Object ( [loginResult] => stdClass Object ( [MobiRegUserID] => 34 [MobiRegUserName] => WJBasson ) ) I need to know how can I get the values of objects MobiRegUserID and MobiRegUserName ?? Hi all, I'm a newbie in PHP trying to move away from the .net platform. I seem to have run into my first challenge passing a complex type back to my web service. The web service is a live test site to test against. I've tested the service on .net and it works fine...but I think I'm missing something as I try porting over to PHP? I've written some short code to keep it simple: <?php $SearchCriteria = array("ObjectType"=>1); $parameters['user'] = "johndoe1"; $parameters['password'] = "snowball"; $parameters['SearchCriteria'] = $SearchCriteria ; $client = new SoapClient("https://servicestest.mcquaig.com/mws.asmx?WSDL"); $result = $client->__soapCall('Find', $parameters); ?> ....against this portion of XML: <s:element name="Find"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="user" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="criteria" type="tns:SearchCriteria"/> </s:sequence> </s:complexType> </s:element> <s:complexType name="SearchCriteria"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="AccountName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="ApplySharing" type="s:boolean"/> <s:element minOccurs="1" maxOccurs="1" name="CGType" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="ClientRefID" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="Composites" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="ConfNo" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="Email" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="Expired" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="ExpiryTSA" type="s:dateTime"/> <s:element minOccurs="1" maxOccurs="1" name="ExpiryTSZ" type="s:dateTime"/> <s:element minOccurs="0" maxOccurs="1" name="FirstName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="FormLangID" type="s:unsignedLong"/> <s:element minOccurs="1" maxOccurs="1" name="FunctionalArea" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Gender" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Industry" type="s:int"/> <s:element minOccurs="0" maxOccurs="1" name="JobTitle" type="s:string"/> <s:element minOccurs="0" maxOccurs="1" name="LastName" type="s:string"/> <s:element minOccurs="1" maxOccurs="1" name="LastUsedTSA" type="s:dateTime"/> <s:element minOccurs="1" maxOccurs="1" name="LastUsedTSZ" type="s:dateTime"/> <s:element minOccurs="1" maxOccurs="1" name="NoRelated" type="s:boolean"/> <s:element minOccurs="1" maxOccurs="1" name="ObjectType" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="OrgID" type="s:unsignedLong"/> <s:element minOccurs="1" maxOccurs="1" name="Position" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="ProfileType" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Recursive" type="s:boolean"/> <s:element minOccurs="1" maxOccurs="1" name="Status" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="Type" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="UnitsRemain" type="s:int"/> <s:element minOccurs="1" maxOccurs="1" name="UnitsRemainGT" type="s:boolean"/> </s:sequence> </s:complexType> Nothing I seem to do works. I end up with the same error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Value does not fall within the expected range. Using NuSoap as: <?php require_once('lib/nusoap.php'); $SearchCriteria = array("ObjectType"=>1); $wsdlURL = "https://servicestest.mcquaig.com/mws.asmx?WSDL"; $soap = new nusoap_client($wsdlURL); $parameters['user'] = "johndoe1"; $parameters['password'] = "snowball"; $parameters['criteria'] = $SearchCriteria ; $result = $soap->call("Find", $parameters); if($error = $soap->getError()){ die($error);} ?> I get this error: soap:Client: Server did not recognize the value of HTTP Header SOAPAction: . I'm stumped and sure it's something small, but I just don't see what I'm missing?? Any suggestions are greatly appreciated!! Gary This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=345200.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 Okay, On my original problem, I have been able to authenticate with the web service login service, and extract a cookie as follows from the web-service: $s_Cookie = $agLoginService->agGetCookie(); $s_Cookie = AGSESSION=oxhbjcKtPw5sOymAD8m8KcKR6JL4i+TIE5mZxwOrXLwCRr8iTOvPxA==; Now, I create data access soapclient: $agDataService = new SoapClient($s_DataURL, $a_SoapOptions); //yes I know I should build my own class wrapper around soapClient, but I am trying to make sure I know what to build before I do next in the process I need to set the cookie for the data access service. I tried using: <b>$agDataService->__setCookie('cookie', $s_Cookie);</b> but I don't think it's right because when I call any of the service's functions, I get no data back. This is what their engineer had to say ( he is no help in php at all) This is a question referring the http headers. He needs to set the cookies as given in the examples on the wiki page. The cookie is specified in a response http header as: Set-Cookie. So the http headers he got back are correct. The cookie he has to set is AGSESSION=oxhbjcKtPw5sOymAD8m8KcKR6JL4i+TIE5mZxwOrXLwCRr8iTOvPxA==; There should be an api for setting the cookie if not there is one for setting the http header. Set the http header name for the request (cookie - notice that is different than what you get back from an http response - read the rfc spec for http for all of the details) then set the value. The semi colon at the end is the delimiter for http headers (in the rfc). That is all he needs to do if he gets back some login error that means the cookies did not get set correctly. Any ideas or help will be great. Thank you. I am trying to store website address in a variable but when I do so the dots in the address are missing. I guess it takes it as string concatenation, for example: $address='www.lottocomplete.com'; will actually give me: wwwlottocompletecom How can I make sure these dots will be preserved? I am also trying to store email address in a variable but I get error, something about @ symbol being in wrong spot, wonder how this can be resolved as well. One more questions relates to the new line issue that I have when I concatenate string, for example if I do the following: $string = "1\n"; $string .= "2\n"; $string .= "3\n"; I would think that each number would be printed on new line but instead it shows up as: 123 What am I doing wrong? Hi I'm setting up my own framework for a project. I was coming to the point of completion and thought up of a new idea. Is it possible to call a function like this from a class: class myClass { function func($param) { echo "Hello world". $param; } } $class = 'myClass'; $func = "func(' It\'s time to partey!')"; $$class = new $class; $$class->$func; Thanks for any help! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=326004.0 Where is my "Progr" return value?
This is not my first day using php but I don't code in the language that often. I don't understand why my dynamic variable is not returned in AJAX GET? Essentially, I need to give the client a simple UI so that they can copy files to a printer and I wanted to provide a little unfiltered feedback so they knew whether operation was a success. My feedback was just going to be output of exec() function though cleaned up slightly (perhaps replace line breaks with html break tags). PHP version is 5.2.17.17 and cannot be upgraded. Web Server Apache.
PHP dumbed down code:
exec("LoadZPL_PURL.bat", $output); This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=348665.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=348384.0 Hi guys, I am trying to implement a Pagination class for a website displaying movies. I need to have the total number of posts, but on accessing the function row_count() from class Connection I get the error: "Fatal error: Uncaught Error: Call to a member function query() on null in ..\connection.php:30 Stack trace: #0 from ...\index.php(20): Connection->row_count() #1 ..." I only found two posts concerning this issue, and they led me to think this might be a scope issue with $db variable; $db is defined in the constructor function of the same Connection class so I thought the scope would be ok; but apparently, not. Can anybody help? This is a real show-stopper just now. Please let me know if you need any further information. Thanks in advance. Sept connection.txt index.txt I don't even know how to explain what I want to do as a subject. >.< Okay, so what I want to do is pull up all the entries in a table, (in this case "horse") for a specific location. Then, I want to pull all the results for that horse from the "result" table. Next, I want to compare each result from that table to a list of if/elseif for points. Finally, I want all the points gathered and totaled and displayed for that horse, and every other horse at that location, in a single page. Here is the coding that I have: Code: [Select] <? ---- connection information is here but removed ----- echo "<table> <tr><td><b>Name</b></td> <td><b>Points</b></td> <td><b>Title</b></td></tr>"; //finds horses at specific location $query = "SELECT * FROM horse WHERE location='DESIRED_LOCATION' ORDER BY name"; $result = mysql_query($query) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $id = $row['id']; $name = $row['name']; //gathers results based upon the above two pieces of information //the include is shown below as it contains the point info include('includes/points.php'); $query92 = "SELECT * FROM results WHERE MAIN_KEY='$id' OR MAIN_KEY = '$name'"; $result92 = mysql_query($query92) or die (mysql_error()); while($row92 = mysql_fetch_array($result92)) { $place = $row92['place']; echo "<tr><td>$name</td> <td>$points</td> <td>$title</td></tr>"; } } echo "</table>"; ?> and this is the points.php file: Code: [Select] <? if($place === '1st') {$points += 50;} elseif($place === '2nd') {$points += 45;} elseif($place === '3rd') {$points += 40;} elseif($place === '4th') {$points += 35;} elseif($place === '5th') {$points += 30;} elseif($place === '6th') {$points += 25;} elseif($place === '7th') {$points += 20;} elseif($place === '8th') {$points += 15;} elseif($place === '9th') {$points += 10;} elseif($place === '10th') {$points += 10;} elseif($place === 'CH') {$points += 50;} elseif($place === 'RCH') {$points += 40;} elseif($place === 'TT') {$points += 30;} elseif($place === 'T5') {$points += 30;} if($points < 500) {$title = "No Title";} elseif ($points >= 500 && $points < 1000) {$title = "Champion";} elseif ($points >= 1000 && $points < 2500) {$title = "Grand Champion";} elseif ($points >= 2500 && $points < 5000) {$title = "State Champion";} elseif ($points >= 5000 && $points < 8000) {$title = "National Champion";} elseif ($points >= 8000 && $points < 10000) {$title = "World Champion";} elseif ($points >= 10000) {$title = "Hall of Fame";} ?> I have a database called "mp_users" with the following setup: Code: [Select] CREATE TABLE IF NOT EXISTS `mp_users` ( `id` int(10) unsigned default NULL auto_increment, `uid` int(10) unsigned NOT NULL, `username` varchar(100) NOT NULL, `email` varchar(50) NOT NULL, `points` int(10) unsigned NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; When I try to run the following query, I get an error: Quote SELECT COUNT(id) AS user_exists FROM `mp_users` WHERE uid=$uid LIMIT 1; Error: Fatal error: Call to a member function query() on a non-object in /home/user/public_html/marketplace-functions.php on line 52 Here is the code: Code: [Select] <?php require_once "config.php"; $sql = new mysqli($db1['host'], $db1['user'], $db1['pass'], $db1['db']); function checkUserExists($uid){ // Query $q = "SELECT COUNT(id) AS user_exists FROM `mp_users` WHERE uid=$uid LIMIT 1;"; echo $q; $q = $sql->query($q); $r = $q->fetch_assoc(); // Any results? if($r['user_exists'] == 0){ // redirect to runonce... header('Location: marketplace.php?do=runonce&return='.urlencode($_SERVER['QUERY_STRING'])); exit(); } } ?> Line 52 is the $q query. I really cannot see what the problem is. The database exists, I've tried it in phpMyAdmin and it runs without trouble, but this wont! Can anyone help? Thanks in advance I am changing my script from connecting to the database within every function, to using one connection (in the main class). However, I am getting an error: Call to a member function query() on a non-object Here is the main class: <?php class main{ // the configuration vars public $config; // the current user variables public $uid = 0; // contains the user ID public $gid = 0; // contains the group ID // database variables public $DB; // contains the connection public $query_id; // contains the query ID public $query_count; // how many queries have there been? // cache variables public $cache; public $test = 'hi'; // initiate public function __construct(){ } // start up functions public function startup(){ // first, set up the caching if($this->config['use_memcache'] == true){ // start up cache require_once('cache.class.php'); $this->cache = new cache_TS(); } // now, set up the DB $this->connectToDatabase(); // now, set up the user session $this->setUserSession(); // are we logged in? If so, update our location if($this->uid > 0){ // update location $this->updateUserSession(); } } // connect to database public function connectToDatabase(){ // connect to database $this->DB = new mysqli($this->config['host'],$this->config['user'],$this->config['pass'],$this->config['db']); // were we able to connect? if(!isset($this->DB)){ // this is an error exit('could not connect to the database.'); } // test query $q = "SELECT id,title FROM topics WHERE id='1' LIMIT 1;"; $q = $this->DB->query($q); $r = $q->fetch_assoc(); echo $r['id'] . $r['title']; // send back return $this->DB; } // some removed.... The test query works fine. It fails he <?php class forum extends main{ public function viewTopic($tid){ // Connect To Database //$sql = new mysqli(db::$config['host'], db::$config['user'], db::$config['pass'], db::$config['db']); // Get assorted details (topic, forum, etc) // Get topic details $tid = intval($tid); $tq = "SELECT * FROM `topics` WHERE id='$tid' LIMIT 1"; $tq = $this->DB->query($tq); $tr = $tq->fetch_assoc(); startup in main has already been called before forum is. The DB connects without failure. Can anyone see what the problem is? How can I get $this->DB->query to work? (The query works fine when it's ran in the main class) This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=330539.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=350021.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=352409.0 Code: [Select] <?php class OnlineStore { private $DBConnect = NULL; private $storeID = ""; private $inventory = array(); private $shoppingCart = array(); function __construct() { include("inc_OnlineStoreDB.php"); $this->DBConnect = $DBConnect; } function __destruct() { if (!$this->DBConnect->connect_error) $this->DBConnect->close(); } public function setStoreID($storeID) { if ($this->storeID != $storeID) { $this->storeID = $storeID; $SQLstring = "SELECT * FROM inventory " . " where storeID = 'jw" . $this->storeID . "'"; $QueryResult = $this->DBConnect->query($SQLstring); if ($QueryResult === FALSE) { $this->storeID = ""; } else { $this->inventory = array(); $this->shoppingCart = array(); while (($Row = $QueryResult->fetch_assoc()) !== NULL) { $this->inventory[$Row['productID']] = array(); $this->inventory[$Row['productID']]['name'] = $Row['name']; $this->inventory[$Row['productID']]['description'] = $Row['description']; $this->inventory[$Row['productID']]['price'] = $Row['price']; $this->shoppingCart[$Row['productID']] = 0; } } } } public function getStoreInformation() { $retval = FALSE; if ($this->storeID != "") { $SQLstring = "SELECT * FROM store_info " . " WHERE storeID = '" . $this->storeID . "'"; $QueryResult = @$this->DBConnect->query($SQLstring); if ($QueryResult !== FALSE) { $retval = $QueryResult->fetch_assoc(); } } return($retval); } public function getProductList() { $retval = FALSE; $subtotal = 0; if (count($this->inventory) > 0) { echo "<table width='100%'>\n"; echo "<tr><th>Product</th><th>Description</th>" . "<th>Price Each</th><th># in Cart</th>" . "<th>Total Price</th><th> </th></tr>\n"; foreach ($this->inventory as $ID => $Info) { echo "<tr><td>" . htmlentities($Info['name']) . "</td>\n"; echo "<td>" . htmlentities($Info['description']) . "</td>\n"; printf("<td class='currency'>$%.2f</td>\n", $Info['price']); echo "<td class='currency'>" . $this->shoppingCart[$ID] . "</td>\n"; printf("<td class='currency'>$%.2f</td>\n", $Info['price'] * $this->shoppingCart[$ID]); echo "<td><a href='" . $_SERVER['SCRIPT_NAME'] . "?PHPSESSID=" . session_id() . "&ItemToAdd=$ID'>Add " . " Item</a></td>\n"; $subtotal += ($Info['price'] * $this->shoppingCart[$ID]); } echo "<tr><td colspan='4'>Subtotal</td>\n"; printf("<td class='currency'>$%.2f</td>\n", $subtotal); echo "<td>$nbsp;</td></tr>\n"; echo "</table>"; $retval = TRUE; } return($retval); } public function addItem() { $ProdID = $_GET['ItemToAdd']; if (array_key_exists($ProdID, $this->shoppingCart)) $this->shoppingCart[$ProdID] += 1; } } ?> having an issue to where nothing is appearing on the page and getting the Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\PHP\Chapter.10\class_OnlineStore.php on line 24 HERE IS THE MAIN PAGE Code: [Select] <?php session_start(); require_once("class_OnlineStore.php"); $storeID = "COFFEE"; $storeInfo = array(); if (class_exists("OnlineStore")) { if (isset($_SESSION['currentStore'])) $Store = unserialize($_SESSION['currentStore']); else { $Store = new OnlineStore(); } $Store->setStoreID($storeID); $storeInfo = $Store->getStoreInformation(); } else { $ErrorMsgs[] = "The OnlineStore class is not available!"; $Store = NULL; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><?php echo $storeInfo['name']; ?></title> <link rel="stylesheet" type="text/css" href="<?php echo $storeInfo['css_file']; ?>" /> </head> <body> <h1><?php echo htmlentities($storeInfo['name']); ?></h1> <h2><?php echo htmlentities($storeInfo['description']); ?></h2> <p><?php echo htmlentities($storeInfo['welcome']); ?></p> <?php $Store->getProductList(); $_SESSION['currentStore'] = serialize($Store); ?> </body> </html> I HAVE REVIEWED IT OVER AND OVER AGAIN AND I CANT SEE THE PROBLEM. MAYBE SOMEONE FROM THE OUTSIDE CAN HELP OUT. |