PHP - Soap With Array Wrong Result
Similar TutorialsI need to have have my request look like this: <filters> <FilterCondition> <FieldName>Lname</FieldName> <Operator>Equals</Operator> <Operands> <xsd:string>Smith</xsd:string> </Operands> </FilterCondition> <FilterCondition> <FieldName>Fname</FieldName> <Operator>Equals</Operator> <Operands> <xsd:string>Robert</xsd:string> </Operands> </FilterCondition> </filters> This is what i have: <filters xsi:type="FilterCondition"> <BOGUS> <FieldName>Lname</FieldName> <Operator>Equals</Operator> <Operands> <xsd:string>Smith</xsd:string> </Operands> </BOGUS> <BOGUS> <FieldName>Fname</FieldName> <Operator>Equals</Operator> <Operands> <xsd:string>Robert</xsd:string> </Operands> </BOGUS> </filters> Using this code: class FilterCondition { function FilterCondition($s, $i, $f) { $this->FieldName = $s; $this->Operator = $i; $this->Operands[] = $f; } } $filter1 = new FilterCondition('Lname', 'Equals', 'Smith'); $filter2 = new FilterCondition('Fname', 'Equals', 'Robert'); $test = new SoapVar(array($filter1, $filter2), SOAP_ENC_OBJECT, 'FilterCondition'); new SoapParam($test, "filters") Any ideas? <SCRIPT LANGUAGE="javascript"> I copied and pasted the code below from php manual, http://www.php.net/manual/en/datetime.diff.php, I should have got the result of '2' as they did but I got the result of '6015'. I can't think why this would be. Any help appreciated. Code: [Select] $datetime1 = new DateTime('2009-10-11'); $datetime2 = new DateTime('2009-10-13'); $interval = $datetime1->diff($datetime2); echo $interval->format('%R%a days'); I have a table korisnici in SQLite with INTEGER field aktivan that can have only 0 or 1 value (CHECK constraint). Field aktivan has value 0 but PHP returns value 1, why? Is this a bug? This is PHP code that I am running: $sql = "SELECT ime, aktivan FROM korisnici WHERE lower(ime) = '" . $ime . "'" . " AND sifra = '" . $_POST["sifra"] . "'"; $result = $db->query($sql); $row = $result->fetchArray(SQLITE3_ASSOC); $row['aktivan'] = 1 but in table the value is 0. When I run same query in DB Browser for SQLite I get correct value 0. Is this a bug? Hello, I'm working with a website's soap services to communicate with their servers, They have sent me a sample code of .Net that works properly for all methods of their web services, But while I'm trying to use the same web services via php-soap the functions that has array of string as a parameter for a method doesn't work at all, ( the other functions work fine ) Here is the sample code of .Net: Code: [Select] webServiceType ws = new webServiceType(); string res = ws.methodX("username", "password", new string[] { "x" , "y" }); but this code in PHP doesn't work fine and throw an exception $client = new SoapClient("http://webserviceURL.com?WSDL",array("features" => SOAP_SINGLE_ELEMENT_ARRAYS)); $response = $client->methodX("username","password",array ( "x" , "y" )); Any suggestion on how to pass an array of string to a method via soap- WSDL? I have a list of ID's returned from a table (even number). I always used a loop to get the next result, but I want to put these straight into a new table INSERT INTO table VALUES ($ID1, $ID2); This is recursive till there are no more ID's. How do I get the result then the next result without loops. ID1 and ID2 cannot be null. What is the best way? I'm self-studying PHP and put to myself to a task. But I can't figure this out. It's about putting a database result into array. There is this database called books with columns: isbn, author,title, price. The DB has records. I want to output certain records of certain columns:for example echo $books['title"];. I also to use functions. I used the following code to titles listing for example: function db_connect() { $result = new mysqli('localhost', 'root', 'password', 'books'); if (!$result) { return false; } $result->autocommit(TRUE); return $result; } function get_book_details($isbn) { // query database for all details for a particular book if ((!$isbn) || ($isbn=='')) { return false; } $conn = db_connect(); $query = "select * from books where isbn='".$isbn."'"; $result = @$conn->query($query); if (!$result) { return false; } $result = @$result->fetch_assoc(); return $result; } $book = get_book_details($isbn); foreach($book as $isbn => $qty){ echo $book['title']; } I have this error: Warning: Invalid argument supplied for foreach() in ..\foreach.php on line 41 I'm guessing that $book is not array that's why I get this error message. But the big problem is as you can see in the function function get_book_details($isbn) inside the function it already gets the result into array $result = @$result->fetch_assoc(); $sql = "SELECT option_id, id FROM bets WHERE win_status = '1' AND updated_at BETWEEN '$today 13:00:00.000000' AND '$tmrw 08:00:00.000000'"; $result = mysqli_query($connt, $sql); foreach($result as $value) { $value[] = arary_multisort(); $oid = $value['option_id']; $gid = $value['id']; var_dump($value); //$gim = var_export($value); } foreach($result as $key => $value) { $info = array($value); } mysqli_close($connt); $fl = array($oid, $gid); print_r($fl);
array ( Either I can return 1 row and have the data sorted nicely or I can return an array but I can only seem to access the last array. Been stuck on this bit for atleast 2 hrs sadly. How can I rename the array? Some days I might have 100 results. Today we have two winners xP I really need to ctrl+z sublime cuz I tried what feels like everything. Ancy to move to the next part of this code MATH if you can kindly assist. Yall have been extremely helpful in my last two posts 2/2 going on 3. Is there a place I can properly contribute lite silver :3 Hello guys I have here my array result Array ( => Array ( => 1 [1] => [2] => 123456789 [3] => [4] => 2012-02-02 [5] => 09:12:21 [6] => Test Array ) ) I would like to view this result into a string so that it will remove the unnecessary array elements like brackets etc. Can some tell me how to handle this properly? The result would be : 1 123456789 2012-02-02 09:12:21 thanks Hi everyone, I really need some help with a project I'm working on. I have a table in MySQL that I am querying to pull out some data. This is the results I am getting from my query: ----------------------------------------------- | fld_id | fld_vl | ----------------------------------------------- | CLNT_NM | Motel1 | | CLNT_MGR | Frank | | CLNT_TMZ | EST | ----------------------------------------------- What I would like to do is get a variable for each fld_id and populate it with the field value. So, in essence it would look like this. $CLNT_NM = 'Motel1'; $CLNT_MGR = 'Frank'; $CLNT_TMZ = 'EST'; How can I do this? I have tried to figure this out but I can't seem to do it. Any help you guys can provide would be greatly appreciated. THANKS in advance!!! This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=353485.0 Hi all, I'm new to PHP have written some code to extract data from mysql. here it is <!DOCTYPE html> <html lang="en"> result 1.png 18.34KB 0 downloads result 2.png 24.62KB 0 downloads Table.png 4.61KB 0 downloads <head> <meta charset="utf-8" /> <title></title> </head> <body> <?php echo "Testing Database....<br>"; $con = mysqli_connect('localhost', 'db_id', 'my_pw', 'mysql_db'); $result = $con->query("SELECT user_id FROM users"); echo "Number of users : ".$result->num_rows."<br><br>"; $row = mysqli_fetch_row($result); echo $row[0]."<br>"; echo $row[1]."<br>"; echo $row[2]."<br>"; ?> </body> </html> in result number of rows its giving right, but when i fetch the result in row, its giving only first row. rest all are empty. then further i have tested few more things like, i change the query as below 'SELECT * FROM users' now this is giving another strange result. It selected first row of the table and making array for all available columns. i have attached herewith image of my table, and result of both of my queries. Could someone guide me on this issue... Hi, I have attached sql script for table structure and sample data. When I run following sql query ,I get result set. Code: [Select] select * from tablename order by col10 desc I want to create array using result set. Following is the require structure of array. Code: [Select] <?php $resultSet[]=array ( ('0') =>array ( ('col10value1') => array ( ('0') => array ( ('col1') => 'col1', ('col2') => 'col2', ('col3') => 'col3', ('col4') => 'col4', ('col5') => 'col5', ('col6') => 'col6', ('col7') => 'col7', ('col8') => 'col8', ), ('1') => array ( ('col1') => 'col1', ('col2') => 'col2', ('col3') => 'col3', ('col4') => 'col4', ('col5') => 'col5', ('col6') => 'col6', ('col7') => 'col7', ('col8') => 'col8', ), ), ), ('1') => array ( ('col10value2') => array ( ('0') => array ( ('col1') => 'col1', ('col2') => 'col2', ('col3') => 'col3', ('col4') => 'col4', ('col5') => 'col5', ('col6') => 'col6', ('col7') => 'col7', ('col8') => 'col8', ), ), ), ); ?> Hi All, I have a select statement $stmt = $conn -> prepare(' SELECT u.user_firstname, u.user_lastname, so.staff_id, r.role_name FROM ssm_staff_order so INNER JOIN ssm_user u on so.staff_id = u.user_id INNER JOIN ssm_role r on u.user_role_id = r.role_id WHERE job_id = ? '); $stmt -> bind_param('i', $jid); $stmt -> execute(); $stmt -> bind_result($fn, $ln, $id, $role); The result looks like this +----------------+---------------+----------+-----------+ | user_firstname | user_lastname | staff_id | role_name | +----------------+---------------+----------+-----------+ | FName | LName | 8 | Chef | | jon | smith | 15 | Manager | | Chelsea | Hockley | 2 | Manager | +----------------+---------------+----------+-----------+ I am wanting to build an array so that i can foreach the result with the people under the header of their role. I know this is not difficult but i am going around and around with it and clearly missing the key part. As always your help is appreciated. Quote from: Hollows on August 20, 2010, 11:29:25 AM I have an array that is pulling 10 results from a db like this - <?php $result = mysql_query("SELECT * FROM inbox ORDER BY id DESC LIMIT 0,10"); while ($row = mysql_fetch_array($result)) { <div class="<?php echo $row['class']; ?>"> <?php echo $row['name']; echo $row['message']; ?> </div> basically 'class' is defined in an earlyier part of the script and is used to tell the css what class to display - as I'm sure you can see. What I'd like todo then be able to update the class of a message once I have read it, so update the class table with something like 'read' so the css will then be based on .read not what ever was set by the form, either using a link or form button inside each of the 10 results from the array. I've managed to update one by using - Code: [Select] mysql_query("UPDATE shoutbox SET class = 'read' WHERE id = ''XX"); // XX should be row id But I had to set that myself and point the id to the row id I wanted to change - How can I have that already populated with the row for the id that triggered it? To be clear so it looks like - Name Message read button _____________ Name Message read button _____________ Name Message read button _____________ and so on... Would I be better going by check boxes and one submit button? If so how could I implement that? I can provide the full code I've written if it helps Thank you in advance I am having a bit of trouble with the following (just for theoretical purposes of course!). Just wondered how you do the following code: $products = array(); // makes a empty array called $products $i = 1; $icol = 1; while($row = mysql_fetch_array($result)) { $products[$i]['product1'] = $row[$icol][0]; $i = $i++; } All its meant to do is: Quote SELECT * FROM products Which the table contains just 3 columns: productid | product | price 1 | product1 | 25.55 That is it, very simple, but wanted to make a multi dimension array that will be 3 columns wide, then however many rows (hence the while loop and array fetch etc). Any help is appreciated, just coming from a VBA background when it comes to the arrays in VB lol. Thanks for any help in advance, Jeremy. Hello, I am fairly new to PHP and I found some php code to print an array of numbers that create a combination - however, its slams all the numbers together without a space or a comma separator. How can I separate the numbers in this array with the given code? Ive attached a photo of the code.
|