Search Results

Search found 224 results on 9 pages for 'associative'.

Page 8/9 | < Previous Page | 4 5 6 7 8 9  | Next Page >

  • Need a regular expression to parse a text body

    - by Ali
    Hi guys, I need a regular expression to parse a body of text. Basically assume this that we have text files and each of which contains random text but within the text there would be lines in the following formats - basically they are a format for denoting flight legs. eg: 13FEB2009 BDR7402 1000 UUBB 1020 UUWW FLT This line of text is always on one line The first word is a date in the format DDMMMYYYY Second word could be of any length and hold alphanumeric characters third word is the time in format HHMM - its always numeric fourth word is a location code - its almost always just alphabets but could also be alphanumeric fifth word is the arrival time in format HHMM - its always numeric sixth word is a location code - its almost always just alphabets but could also be alphanumeric Any words which follow on the same line are just definitions A text file may contain among lots of random text information one or more such lines of text. I need a way to be able to extract all this information i.e just these lines within a text file and store them with their integral parts separated as mentioned in an associative array so I have something like this: array('0'=>array('date'=>'', 'time-dept'=>'', 'flightcode'=>'',....)) I'm assuming regular expressions would be in order here. I'm using php for this - would appreciate the help guys :)

    Read the article

  • Help with fql.multiQuery

    - by Daniel Schaffer
    I'm playing around with the Facebook API's fql.multiQuery method. I'm just using the API Test Console, and trying to get a successful response but can't seem to figure out exactly what it wants. Here's the text I'm entering into the "queries" field: {"tags" : "select subject from photo_tag where subject != 601599551 and pid in ( select pid from photo_tag where subject = 601599551 ) and subject in ( select uid2 from friend where uid1 = 601599551 )", "foo" : "select uid from user where uid = 601599551"} All it'll give me is a queries parameter: array expected. error. I've also tried just about every permutation I could think of involving wrapping the name/query pairs in their own curly braces, adding brackets, adding whitespace, removing whitespace in case it didn't want an associative array (for those watching the edits, I just found out about these wonderful things now... oy), all to no avail. Is there something painfully obvious I'm missing here, or do I need to make like Chuck Norris Jon Skeet and simply will it to do my bidding? Update: A note to anyone finding this question now: The fql.multiquery test console appears to be broken. You can test your query by clicking on the generated url in the test console and manually adding the "queries" parameter into the querystring.

    Read the article

  • What is the best way to parse Paypal NVP in PHP?

    - by xsaero00
    I need a function that will correctly parse NVP into PHP array. I have been using code provided by paypal but it did not work for when string length was specified next to the name. Here is what i have so far. private function parseNVP($nvpstr) { $intial=0; $nvpArray = array(); while(strlen($nvpstr)) { //postion of Key $keypos= strpos($nvpstr,'='); //position of value $valuepos = strpos($nvpstr,'&') ? strpos($nvpstr,'&'): strlen($nvpstr); /*getting the Key and Value values and storing in a Associative Array*/ $keyval=substr($nvpstr,$intial,$keypos); $vallength=$valuepos-$keypos-1; // check if the length is explicitly specified if($braketpos = strpos($keyval,'[')) { // override value length $vallength = substr($keyval,$braketpos+1,strlen($keyval)-$braketpos-2); // get rid of brackets from key name $keyval = substr($keyval,0,$braketpos); } $valval=substr($nvpstr,$keypos+1,$vallength); //decoding the respose if (isValidXMLString("<".urldecode($keyval).">".urldecode( $valval)."</".urldecode($keyval).">")) $nvpArray[urldecode($keyval)] =urldecode( $valval); $nvpstr=substr($nvpstr,$keypos+$vallength+2,strlen($nvpstr)); } return $nvpArray; } This function works most of the time.

    Read the article

  • TCL TDom: Looping through Objects

    - by pws5068
    Using TDom, I would like to cycle through a list of objects in the following format: <object> <type>Hardware</type> <name>System Name</name> <description>Basic Description of System.</description> <attributes> <vendor>Dell</vendor> <contract>MM/DD/YY</contract> <supportExpiration>MM/DD/YY</supportExpiration> <location>Building 123</location> <serial>xxx-xxx-xxxx</serial> <mac>some-mac-address</mac> </attributes> </object> <object> <type>Software</type> <name>Second Object</name> ... Then I use TDom to make a list of objects: set dom [dom parse $xml] set doc [$dom documentElement] set nodeList [$doc selectNodes /systems/object] So far I've done this to (theoretically) select every "Object" node from the list. How can I loop through them? Is it just: foreach node $nodeList { For each object, I need to retrieve the association of each attribute. From the example, I need to remember that the "name" is "System Name", "vendor" is "Dell", etc. I'm new to TCL but in other languages I would use an object or an associative list to store these. Is this possible? Can you show me an example of the syntax to select an attribute in this manner?

    Read the article

  • Manipulating jQuery to retrieve the onclick function of an item which lies directly below the curren

    - by Stevie Jenowski
    First off, I want to thank you for looking into my question as I really do appreciate your time. I've built a list of items using php by having a foreach loop cycle through an associative array printing the array data as parameters of an onclick function call and gives each item it cycles through an ID of $thecount. All items retrieved have the same parent div and calls the very same onclick function, only with 11 different parameters. My question is how do I go about calling the onClick("function();") of an item directly below the current focus, making it the new focus, only without a physical click? If this is confusing to you whatsoever, I'm essentially building a dynamic playlist, and I've already implemented the listener for when the player's current item has finished playing, Now I'm having trouble grasping how I'd go about having the next item in the list become the new focus while also calling it's specific onClick() function once the player returns that it has finished with the current file. All without any user interaction besides the initial play call. If it helps I'm using the most recent release of Longtails' JW Player and once again thank you very much for your time!

    Read the article

  • Generic unit test scheduling

    - by Raphink
    Hello, I'm (re)writing a program that does generic unit test scheduling. The current program is a mono-threaded Perl program, but I'm willing to modularize it and parallelize the tests. I'm also considering rewriting it in Python. Here is what I need to do: I have a list of tests, with the following attributes: uri: a URI to test (could be HTTP/HTTPS/SSH/local) ; depends: an associative array of tests/values that this test depends on ; join: a list of DB joints to be added when selecting items to process in this test ; depends_db: additional conditions to add to the DB request when selecting items to process in this test. The program builds a dependency tree, beginning with the tests that have no dependencies ; for each test: a list of items is selected from the database using the conditions (results of depending tests, joints and depends_db) ; the list of items is sent to the URI (using POST or stdin) ; the result is retrived as a YAML file listing the state and comments for the test for each tested item ; the results are stored in the DB ; the test returns, allowing depending tests to be performed. the program generates reports (CSV, DB, graphviz) of the performed tests. The primary use of this program currently is to test a fleet of machines against services such as backup, DNS, etc. The tests can then be: - backup: hosted on the backup machine(s), called through HTTP, checks if the machines' backup went well ; - DNS: hosted on the local machine, called via stdin, checks if the machines' fqdn have a valid DNS entry. Does such a tool/module already exist? What would be the best implementation to achieve this (using Perl or Python)?

    Read the article

  • How do I combine two arrays in PHP based on a common key?

    - by Eoghan O'Brien
    Hi, I'm trying to join two associative arrays together based on an entry_id key. Both arrays come from individual database resources, the first stores entry titles, the second stores entry authors, the key=value pairs are as follows: array ( 'entry_id' => 1, 'title' => 'Test Entry' ) array ( 'entry_id' => 1, 'author_id' => 2 I'm trying to achieve an array structure like: array ( 'entry_id' => 1, 'author_id' => 2, 'title' => 'Test Entry' ) Currently, I've solved the problem by looping through each array and formatting the array the way I want, but I think this is a bit of a memory hog. $entriesArray = array(); foreach ($entryNames as $names) { foreach ($entryAuthors as $authors) { if ($names['entry_id'] === $authors['entry_id']) { $entriesArray[] = array( 'id' => $names['entry_id'], 'title' => $names['title'], 'author_id' => $authors['author_id'] ); } } } I'd like to know is there an easier, less memory intensive method of doing this?

    Read the article

  • Getting a key in the ActionScript Dictionary

    - by Rudy
    Hello, I am using a Dictionary in ActionScript as a queue, sort of, still reading most of the time as an associative container, but I need one time to make a loop to run through the whole dictionary, such as for (var key:String in queue) . Inside this for loop I perform some actions on an element and then call delete on that key. My issue is that I would like to wait for an Event before fetching the next element in this queue. Basically my for loop runs too fast. I would like to fetch the next key all the time, but I know there is no built in method. A solution I thought is to add a break to the loop, as the for.. in will automatically fetch the next key, but it would be a loop which always executes one time, simply to fetch the next key. This sounds a bit counter intuitive. I hope my problem makes sense and I really look for some better ideas than what I currently have. Thanks for your help! Rudy

    Read the article

  • Type conversion between PHP client and Java webservice

    - by a1ex07
    I have a web service implemented as EJB. One of it's methods returns Map<String,String>. On client side I use php : $client = new SoapClient($wsdl,array("cache_wsdl"=>WSDL_CACHE_NONE)); $result = $client->foo($params); Everything works fine, but I would like $result-return to be an associative array. Now it looks like array(10) { [0]=> object(stdClass)#46 (2) { ["key"]=> string(4) "key1" ["value"]=> string(4) "val1" } .... I want array(10) {"key1"=>"value1", "key2"=>"value2", .... } The obvious solution is to iterate through this array and create a new array $arr = array(); foreach ($result->return as $val) $arr[$val->key] = $val->value; But I wonder if there is a better way to get an assosicative array ? Thanks in advance.

    Read the article

  • User preferences using SQL and JavaScript

    - by Shyam
    Hi, I am using Server Side JavaScript - yes, I am actually using Server Side JavaScript. To complexify things even more, I use Oracle as a backend database (10g). With some crazy XSLT and mutant-like HTML generation, I can build really fancy web forms - yes, I am aware of Rails and other likewise frameworks and I choose the path of horror instead. I have no JQuery or other fancy framework at my disposal, just plain ol' JavaScript that should be supported by the underlying engine called Mozilla Rhino. Yes, it is insane and I love it. So, I have a bunch of tables at my disposal and some of them are filled with associative keys that link to values. As I am a people pleaser, I want to add some nifty user-preference driven solutions. My users have all an unique user_id and this user_id is available during the entire session. My initial idea is to have a user preference table, where I have "three" columns: user_id, feature and pref_string. Using a delimiter, such as : or - (haven't thought about a suitable one yet), I could like store a bunch of preferences as a list and store its elements inside an array using the .split-method (similar like the PHP-explode function). The feature column could be like the table name or some identifier for the "feature" i want to link preferences too. I hate hardcoding objects, especially as I want to be able to back these up and reuse this functionality application-wide. Of course I would love better ideas, just keep in mind I cannot just add a library that easily. These preferences could be like "joined" to the table, so I can query it and use its values. I hope it doesn't sounds too complex, because well.. its basically something really simple I need. Thanks!

    Read the article

  • array or list into Oracle using cfprocparam

    - by Travis
    I have a list of values I want to insert into a table via a stored procedure. I figured I would pass an array to oracle and loop through the array but I don't see how to pass an array into Oracle. I'd pass a list but I don't see how to work with the list to turn it into an array using PL/SQL (I'm fairly new to PL/SQL). Am I approaching this the wrong way? Using Oracle 9i and CF8. TIA! EDIT Perhaps I'm thinking about this the wrong way? I'm sure I'm not doing anything new here... I figured I'd convert the list to an associative array then loop the array because Oracle doesn't seem to work well with lists (in my limited observation). I'm trying to add a product, then add records for the management team. -- product table productName = 'foo' productDescription = 'bar' ... ... etc -- The managementteam table just has the id of the product and id of the users selected from a drop down. The user IDs are passed in via a list like "1,3,6,20" How should I go about adding the records to the management team table?

    Read the article

  • Variable amount of columns returned in mysqli prepared statement

    - by manyxcxi
    I have a situation where a dynamic query is being generated that could select anywhere from 1 to over 300 different columns across multiple tables. It currently works fine just doing a query, however the issue I'm running into in using a prepared statement is that I do not know how to handle the fact that I don't know how many columns I will be asking for each time and therefor don't know how to process the results. The reason I believe a bind statement will help is because once this query is run once, it will most likely (though not always) be run again with the exact same parameters. Currently I have something like this: $rows = array(); $this->statement = $this->db->prepare($query); $this->statement->bind_param('i',$id); $this->statement->execute(); $this->statement->bind_result($result); while($this->statement->fetch()) { $rows[] = $result; } I know this doesn't work as I want it to, my question is how do I get the data back out of the query. Is it possible to bring the columns back in an associative array by column name, like a standard mysqli query?

    Read the article

  • (PHP) Converting an array of arrays from one format into another

    - by Richard Carter
    Hi, I currently have an array, created from a database, an example of which looks like the following: Array( [0] => Array ( objectid => 2, name => title, value => apple ), [1] => Array ( objectid => 2, name => colour, value => red ), [2] => Array ( objectid => 3, name => title, value => pear ), [3] => Array ( objectid => 3, name => colour, value => green ) ) What I would like to do is group all the items in the array by their objectid, and convert the 'name' values into keys and 'value' values into values of an associative array....like below: Array ( [0] => Array ( objectid => 2, title => apple, colour => red ), [1] => Array ( objectid => 3, title => pear, colour => green ) ) I've tried a few things but haven't really got anywhere.. Any ideas? Thanks in advance

    Read the article

  • php multidimensional array as name value pair

    - by Ayad Mfs
    For ecommerce, that expected name value pair I have the following approved code: function create_example_purchase() { set_credentials(); $purchase = array( 'name' => 'Digital Good Purchase Example', 'description' => 'Example Digital Good Purchase', 'amount' => '12.00', // sum of all item_amount 'items' => array( array( // First item 'item_name' => 'First item name', 'item_description' => 'a description of the 1st item', 'item_amount' => '6.00', 'item_tax' => '0.00', 'item_quantity' => 1, 'item_number' => 'XF100', ), array( // Second item 'item_name' => 'Second Item', 'item_description' => 'a description of the 2nd item', 'item_amount' => '3.00', 'item_tax' => '0.00', 'item_quantity' => 2, 'item_number' => 'XJ100', ), ) ); return new Purchase( $purchase); } I would like to get $items Array inside associative $purchase array dynamically from shipping cart. Is there a way to generate exactly the same output above? My dirty solution, to write $purchase array as string inclusive the generated $items array in a file and include it later in the called script. Help appreciated.

    Read the article

  • Bulletin board - Database optimisation

    - by andrew
    This question is a follow on from this Question The project and problem The project I am currently working on is a bulletin board for a large non-profit organisation. The bulletin board will be used to allow inter-office communication within the organisation. I am building the application and have been having trouble extracting the results that I need from my database because I don't think it is properly normalized and because of limitations in my knowledge of relational database theory and mysql. I would appreciate input into the design of the board in general and in particular, ways that the database structure can be improved to facilitate efficient queries and help me develop this application and future application faster Business Logic The bulletin board will be used in the following way Posting bulletins and responses to bulletins Employees or 'users' in offices around the country will be able to post messages to the bulletin board.Bulletins must be posted to a location and categorised- i'll call these "bulletins". Users will be able to post any number of replies to any one bulletin and users will be able to reply to their own bulletin - i'll call these 'replies'. Rating bulletins and replies Users will be able to either 'like' or 'dislike' a bulletin or a reply and the total number of likes or dislikes will be shown for each bulletin or reply. Viewing the bulletin board and responses Bulletins can be displayed chronologically. Users can sort bulletins chronologically or chronologically by the latest reply to that bulletin(let me know if you need more explanation) When a particular bulletin is selected, replies to that bulletin will be displayed chronologically @PerformanceDBA - edited 10:34 est 28/12/10I have begun implementing the data model. I assume that the 6th data model is the physical model because it contains the associative tables. I am going to post any questions that I have below. I will put up a database dump once I am done. I will then put up a list of all the queries that I need to run on the database and begin writing them. I hope you had a good Christmas. I'm in Canada and there's snow! Implementation of Physical model

    Read the article

  • How to extract part of the path and the ending file name with Regex?

    - by brasofilo
    I need to build an associative array with the plugin name and the language file it uses in the following sequence: /whatever/path/length/public_html/wp-content/plugins/adminimize/languages/adminimize-en_US.mo /whatever/path/length/public_html/wp-content/plugins/audio-tube/lang/atp-en_US.mo /whatever/path/length/public_html/wp-content/languages/en_US.mo /whatever/path/length/public_html/wp-content/themes/twentyeleven/languages/en_US.mo Those are the language files WordPress is loading. They are all inside /wp-content/, but with variable server paths. I'm looking only for those inside the plugins folder, grab the plugin folder name and the filename. Hipothetical case in PHP, where reg_extract_* functions are the parts I'm missing: $plugins = array(); foreach( $big_array as $item ) { $folder = reg_extract_folder( $item ); if( 'plugin' == $folder ) { // "folder-name-after-plugins-folder" $plugin_name = reg_extract_pname( $item ); // "ending-mo-file.mo" $file_name = reg_extract_fname( $item ); $plugins[] = array( 'name' => $plugin_name, 'file' => $file_name ); } } [update] Ok, so I was missing quite a basic function, pathinfo... :/ No problem to detect if /plugins/ is contained in the array. But what about the plugin folder name?

    Read the article

  • Php JSON Response Array

    - by Nick Kl
    I have this php code. As you can see i query a mysql database through a function showallevents. I return a the $result to the $event variable. I try to return all rows of the data that i take with the msql_fetch_assoc. I don't get response even when i encode the $response variable. It returns null to all fields. Can anyone help me on what i am doing wrong. I had a valid code but it was returning only 1 row of data so i tried to make an associative array but seems i am failing. if ($tag == 'showallevents') { // Request type is show all events // show all events $event = $db->showallevents(); if ($event != false) { $data = array(); while($row = mysql_fetch_assoc($event)) { $data[] = array( $response["success"] = 1, $response["uid"] = $event["uid"], $response["event"]["date"] = $event["date"], $response["event"]["hours"] = $event["hours"], $response["event"]["store_name"] = $event["store_name"], $response["event"]["event_information"] = $event["event_information"], $response["event"]["event_type"] = $event["event_type"], $response["event"]["Phone"] = $event["Phone"], $response["event"]["address"] = $event["address"], $response["event"]["created_at"] = $event["created_at"], $response["event"]["updated_at"] = $event["updated_at"]); } echo json_encode($data); } else { // event not found // echo json with error = 1 $response["error"] = 1; $response["error_msg"] = "Events not found"; echo json_encode($response); } } else { echo "Access Denied"; } } ?>

    Read the article

  • How to combine these two PHP arrays ?

    - by Annan
    I have two arrays in php that are part of an image management system. weighted_images A multidimensional array. Each sub array is an associative array with keys of 'weight' (for ordering by) and 'id' (the id of the image). array( 156 => array('weight'=>1, 'id'=>156), 784 => array('weight'=>-2, 'id'=>784), ) images This array is user input. It's an array of image ids. array(784, 346, 748) I want to combine them in to a single array of ids ordered by the weight of the image. If an image doesn't have a weight append to the end. It's not a particularly hard problem however my solution is far from elegant and can't help thinking that there must be a better way to do this. $t_images = array(); foreach ($weighted_images as $wi) { if ( in_array($wi['id'], $images) ) { $t_images[$wi['weight']] = $wi['id']; } } foreach ($images as $image) { if ( !$weighted_images[$image] ) { $t_images[] = $image; } } $images = $t_images; Question: Is there a better way to do this?

    Read the article

  • Can you catch exceeded allocated memory error before it kills the script?

    - by kristovaher
    The thing is that I want to catch memory problems before they happen. I have a system that gets rows from database and casts the returned associative array to a variable, but I never know what the size of the database result is is or how much memory it will take once the database request is made. This means that my software can fail simply because memory is exceeded. But I want to avoid that somehow. One of the ways is to obviously make database requests that are smaller, but what if this is not possible or what if I do not know the size of data that is returned from database? Is it possible to 'catch' situations where memory use is exceeded in PHP? Something like this: $requestOk=memory_test(function(){ return doSomething(); }); if($requestOk){ // Memory seems fine // $requestOk now has the value from memory_test() function } else { // Function would have exceeded memory } I just find it problematic that my script can just die at any moment because of memory issues. From what I know, try-catch cannot be used here because it is a fatal error. Any help would be appreciated!

    Read the article

  • How can I get a iterable resultset from the database using pdo, instead of a large array?

    - by Tchalvak
    I'm using PDO inside a database abstraction library function query. I'm using fetchAll(), which if you have a lot of results, can get memory intensive, so I want to provide an argument to toggle between a fetchAll associative array and a pdo result set that can be iterated over with foreach and requires less memory (somehow). I remember hearing about this, and I searched the PDO docs, but I couldn't find any useful way to do that. Does anyone know how to get an iterable resultset back from PDO instead of just a flat array? And am I right that using an iterable resultset will be easier on memory? I'm using Postgresql, if it matters in this case. . . . The current query function is as follows, just for clarity. /** * Running bound queries on the database. * * Use: query('select all from players limit :count', array('count'=>10)); * Or: query('select all from players limit :count', array('count'=>array(10, PDO::PARAM_INT))); **/ function query($sql_query, $bindings=array()){ DatabaseConnection::getInstance(); $statement = DatabaseConnection::$pdo->prepare($sql_query); foreach($bindings as $binding => $value){ if(is_array($value)){ $statement->bindParam($binding, $value[0], $value[1]); } else { $statement->bindValue($binding, $value); } } $statement->execute(); // TODO: Return an iterable resultset here, and allow switching between array and iterable resultset. return $statement->fetchAll(PDO::FETCH_ASSOC); }

    Read the article

  • SQL return ORDER BY result as an array

    - by EarthMind
    Is it possible to return groups as an associative array? I'd like to know if a pure SQL solution is possible. Note that I release that I could be making things more complex unnecessarily but this is mainly to give me an idea of the power of SQL. My problem: I have a list of words in the database that should be sorted alphabetically and grouped into separate groups according to the first letter of the word. For example: ape broom coconut banana apple should be returned as array( 'a' => 'ape', 'apple', 'b' => 'banana', 'broom', 'c' => 'coconut' ) so I can easily created sorted lists by first letter (i.e. clicking "A" only shows words starting with a, "B" with b, etc. This should make it easier for me to load everything in one query and make the sorted list JavaScript based, i.e. without having to reload the page (or use AJAX). Side notes: I'm using PostgreSQL but a solution for MySQL would be fine too so I can try to port it to PostgreSQL. Scripting language is PHP.

    Read the article

  • How can I serialize functions using JSON or some other serialization library?

    - by Oragamster
    I am trying to create a program that uses javascript to write a simple textadventure that I can then post on my blog and run on my iphone. I have run into a problem though. I was trying to make it so that my program would save it's state into cookies using JSON to convert it into strings and then post it into a cookie but then I realised that I couldn't serialize the functions that are on my item object. I was trying to make it so that my item would have an associative array that would contain the name of the use as the key and the function as the value. This worked well untill I tried to serialize it. I learned that I could create a JSON like serialization for functions by storing the body into a string and using escape charectors for the double quotes but for some reason I was unable to make my cookie with the function as the string stored. When I posted the cookie and then tried to get it back the string wasn't there. My code and the over all project are on my site if you want to look at that, though my full code including the item actions are not posted yet.

    Read the article

  • Reference problem when returning an object from array in PHP

    - by avastreg
    I've a reference problem; the example should be more descriptive than me :P I have a class that has an array of objects and retrieve them through a key (string), like an associative array: class Collection { public $elements; function __construct() { $this->elements = array(); } public function get_element($key) { foreach($this->elements as $element) { if ($element->key == $key) { return $element; break; } } return null; } public function add_element ($element) { $this->elements[] = $element; } } Then i have an object (generic), with a key and some variables: class Element { public $key; public $another_var; public function __construct($key) { $this->key = $key; $this->another_var = "default"; } } Now, i create my collection: $collection = new Collection(); $collection->add_element(new Element("test1")); $collection->add_element(new Element("test2")); And then i try to change variable of an element contained in my "array": $element = $collection->get_element("test1"); $element->another_var = "random_string"; echo $collection->get_element("test1")->another_var; Ok, the output is random_string so i know that my object is passed to $element in reference mode. But if i do, instead: $element = $collection-get_element("test1"); $element = null; //or $element = new GenericObject(); $element-another_var = "bla"; echo $collection-get_element("test1")-another_var; the output is default like if it lost the reference. So, what's wrong? I have got the references to the variables of the element and not to the element itself? Any ideas?

    Read the article

  • Getting Response From Jquery JSON

    - by Howdy_McGee
    I'm having trouble getting a response from my php jquery / json / ajax. I keep combining all these different tutorials together but I still can't seem to pull it all together since no one tutorial follow what I'm trying to do. Right now I'm trying to pass two arrays (since there's no easy way to pass associative arrays) to my jquery ajax function and just alert it out. Here's my code: PHP $names = array('john doe', 'jane doe'); $ids = array('123', '223'); $data['names'] = $names; $data['ids'] = $ids; echo json_encode($data); Jquery function getList(){ $.ajax({ type: "GET", url: 'test.php', data: "", complete: function(data){ var test = jQuery.parseJSON(data); alert(test.names[0]); alert("here"); } }, "json"); } getList(); In my html file all I'm really calling is my javascript file for debugging purposes. I know i'm returning an object but I'm getting an error with null values in my names section, and i'm not sure why. What am I missing? My PHP file returns {"names":["john doe","jane doe"],"ids":["123","223"]} It seems to be just ending here Uncaught TypeError: Cannot read property '0' of undefined so my sub0 is killing me.

    Read the article

  • How to current snapshot of MySQL Table and store it into CSV file(after creating it) ?

    - by Rachel
    I have large database table, approximately 5GB, now I wan to getCurrentSnapshot of Database using "Select * from MyTableName", am using PDO in PHP to interact with Database. So preparing a query and then executing it // Execute the prepared query $result->execute(); $resultCollection = $result->fetchAll(PDO::FETCH_ASSOC); is not an efficient way as lots of memory is being user for storing into the associative array data which is approximately, 5GB. My final goal is to collect data returned by Select query into an CSV file and put CSV file at an FTP Location from where Client can get it. Other Option I thought was to do: SELECT * INTO OUTFILE "c:/mydata.csv" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY "\n" FROM my_table; But I am not sure if this would work as I have cron that initiates the complete process and we do not have an csv file, so basically for this approach, PHP Scripts will have to create an CSV file. Do a Select query on the database. Store the select query result into the CSV file. What would be the best or efficient way to do this kind of task ? Any Suggestions !!!

    Read the article

< Previous Page | 4 5 6 7 8 9  | Next Page >