PHP - Json - How To Check If This Is Installes On Opensuse 13.1
json - how to check if this is installes on opensuse 13.1
can i chek it with the terminal? Similar TutorialsI want to add a note field and a checkbox to my list/grid page and save this information to a json file using uomptrucknumber as the key. The note information will be information for the whole truck not by order. The check box will let them know that the truck is ready to have paper work printed. I have not add the note field or checkbox because I did not want to start off wrong. echo "<table>"; echo "<tr style='background:#82fbfd'>"; echo "<th>ShipDate</th>"; echo "<th>ShipMeth</th>"; echo "<th>Name</th>"; echo "<th>LoadID</th>"; echo "<th>Drop</th>"; echo "<th>OrderID</th>"; echo "<th>Status</th>"; echo "<th>FGI</th>"; echo "<th>FGM</th>"; echo "<th>TotalBox</th>"; echo "<th>Cubes</th>"; echo "<th>Total</th>"; echo "<th>Notes \n</th>"; //echo "<table>"; echo "<tr style='background:#82fbfd'>"; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } function ShowDetail($row){ if($row['ompclosed']==-1){ $theColor="#AAF0D2"; }else{ $theColor="#FFFFFF"; } if($row['ompclosed']==0 && $row['date'] < date("m/d/Y")) { $theColor="#FF0000"; } echo "<tr style='background-color :$theColor'><td>" .$row['date'] ."</td>"; echo "<td>" .$row['ompshippingmethodid'] ."</td>"; echo "<td style='text-align:left'>" .$row['cmoname'] ."</td>"; echo "<td>" .$row['uomptrucknumber'] ."</td>"; echo "<td>" .$row['uompdropsequence'] ."</td>"; echo "<td>" .$row['ompsalesorderid'] ."</td>"; echo "<td>" .$row['ompclosed'] ."</td>"; echo "<td>" .round($row['FGIqty'],0) ."</td>"; echo "<td>" .round($row['FGMqty'],0) ."</td>"; echo "<td>" .round($row['uomptotalboxcount'],0) ."</td>"; echo "<td>" . number_format($row['uompvolumetotal'],2) ."</td>"; echo "<td>" . number_format($row['ompordertotalbase'],2) ."</td>"; echo "<td style='text-align:left'>" .$row['ompordercommentstext'] ."</td></tr>" ; } //**************************************************************** while ($row = odbc_fetch_array($result)) { if($row['ompclosed']==-1){ $theColor="#AAF0D2"; }else{ $theColor="#FFFFFF"; } if($row['ompclosed']==0 && $row['date'] < $today) { $theColor="#FF0000"; } if($row['uomptrucknumber'] != $loadid) { if ($loadid !== 0) { echo "<tr style='background:#eee'> <td colspan='7'>TOTAL</td> <td>$TotalFGI</td> <td>$TotalFGM</td> <td> </td> <td> </td> <td>$loadTotal</td> </tr>"; } $TotalFGI=0; $TotalFGM=0; $loadTotal=0; } ShowDetail($row); $loadid = $row['uomptrucknumber']; $TotalFGI+=round($row['FGIqty'],0); $TotalFGM+=round($row['FGMqty'],0); $loadTotal +=$row['ompordertotalbase']; } echo "<tr style='background:#eee'> <td colspan='7'>TOTAL</td> <td>$TotalFGI</td> <td>$TotalFGM</td> <td> </td> <td> </td> <td>$loadTotal</td> </tr> </table>"; odbc_close($connect); ?>
Hello Community, good evening! i am having troubles with starting PHP on linux - [running OpenSuse-Linux] Could not open input file: - suse-linux:/usr/perl # php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/extensions/readline.so' - libedit.so.0: cannot open shared object file: No such file or directory in Unknown on line 0 PHP 5.3.4-dev (cli) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies suse-linux:/usr/perl # well what is wrong here...? This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=353736.0 hello dear php-freaks
at the moment i am installing and investigating.
i have several notebooks here.
i install linux and besides these tasks - i test several notebooks.
i need to test harddrives.
question: how to run smartmonttools on opensuse i found out that this package is one of the best ones http://www.smartmontools.org/ is the package allready installed on opensuse 13.2? i need to run it to check the healthy of the hdd btw: is smart - allready included in the gparted-Live-DvD This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350982.0 try to install orm peewee on opensuse 13. 1 but unfortunatly it failed martin@linux-70ce:~> martin@linux-70ce:~> git clone https://github.com/coleifer/peewee.git Klone nach 'peewee'... remote: Reusing existing pack: 5673, done. remote: Counting objects: 13, done. remote: Compressing objects: 100% (13/13), done. remote: Total 5686 (delta 2), reused 0 (delta 0) Empfange Objekte: 100% (5686/5686), 3.54 MiB | 102.00 KiB/s, done. Löse Unterschiede auf: 100% (3468/3468), done. Prüfe Konnektivität... Fertig martin@linux-70ce:~> cd peewee martin@linux-70ce:~/peewee> python setup.py install running install error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/test-easy-install-5717.write-test' The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: /usr/lib/python2.7/site-packages/ Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: https://pythonhosted.org/setuptools/easy_install.html Please make the appropriate changes for your system and try again. martin@linux-70ce:~/peewee> what can i do now good day PHP-test on OpenSuse Linux 11.3 - ugliest errors (garbage code wherever i look) - i get seasick - this is too much to me. I am willing to throw the computer out of the windows... Well to begin with the beginning: i am brandnew to PHP on OpenSuse 11.3 i just start with PHP while running a first test - this here <?php echo date("Y/m/d") . "<br />"; echo date("Y.m.d") . "<br />"; echo date("Y-m-d") ?> i get ugly Effekts see the output suse-linux:/usr/perl # php learnmecha.php PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /usr/perl/learnmecha.php on line 2 2010/11/15<br />PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /usr/perl/learnmecha.php on line 3 2010.11.15<br />PHP Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /usr/perl/learnmecha.php on line 4 suse-linux:/usr/perl # well - can i say that php runs - but not safe or what is this -- do you have another test - i want to test if the PHP runs well !? well good moring dear folks - hope you are all right and everythings is fine across the atlantic today i have a question regarding server-paths - and the absolute and relative in a linux-[opensuse 11.4] lampp-system well i just installed something in to my Lampp on openSuse 11.4 while setting up this application - (it is a joomla 1.7.3 ) i wonder how i name the paths public $unicodeslugs = '0'; public $feed_limit = '10'; public $log_path = 'D:\\Xammp\\xampp\\htdocs\\pre1/logs'; public $tmp_path = 'D:\\Xammp\\xampp\\htdocs\\pre1/tmp'; public $lifetime = '15'; public $session_handler = 'database'; what cou you thinks how shoud i name the paths well you see above this was a windows box where the pahts originally were taken from love to hear from you hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 I have some PHP which sends some user provided data to the client:
<?php header('Content-type: application/json'); $data=array( array('id'=>10,'firstname'=>'John','lastname'=>'Doe'), array('id'=>14,'firstname'=>'Jane','lastname'=>'Doe'), array('id'=>19,'firstname'=>'XSS!','lastname'=>'XSS!'), ); echo(json_encode($data)); ?>The client then displays the data: $.getJSON('getJSON.php', { something: 123 }, function(list) { var string = ''; for (var i in list) { string += '<li>< a href = "index.php?id=' + list[i]['id'] + '">' + list[i]['firstname'] + '</a></li>'; } $("#MyElem").html(string); });Does this represent any XSS risk? If so, how do I prevent it? how can i also output $pages number into the json as well so i can use it for jquery Code: [Select] <?php // Start Buffer ob_start(); // Load Settings require '../../includes/config.inc.php'; // Require the database connection: require(MYSQL); // Number of records to show per page: $display = 6; // Determine how many pages there are... if (isset($_GET['p']) && is_numeric($_GET['p'])) { // Already been determined. $pages = $_GET['p']; }else{ // Need to determine. // Default Query $count_q = "SELECT COUNT(id) FROM deals"; // Count the number of records: $r = @mysqli_query ($dbc, $count_q); $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil ($records/$display); } else { $pages = 1; } } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } // Make the query: $q = "SELECT id, url, views, deal_img, title, savings, DATE_FORMAT(expiry, '%a, %d %b %Y') AS expr FROM deals ORDER BY created_on DESC LIMIT $start, $display"; $r = @mysqli_query ($dbc, $q); // Run the query. if (mysqli_num_rows($r) > 0) { // Available. /* create one master array of the records */ $offers = array(); while ($offer = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $offers[] = array("id" => $offer["id"], "url" => BASE_APP_URL.'offer/'.$offer["url"].'/', "views" => $offer["views"], "image" => BASE_URL.'niftyuk-deal/'.$offer["deal_img"], "title" => $offer["title"], "savings" => $offer["savings"], "expr" => $offer["expr"]); } // End of WHILE loop. } /* output in necessary format */ header('Content-type: application/json'); echo json_encode($offers); ?> My script is not acting like it should. I believe its because of the recent change in the api, (the new error array)? Before there was only one.... <?php $gamertag = 'l RaH l'; $url = "http://api.xboxleaders.com/user_api.php?gamertag=".str_replace(' ', '%20', $gamertag); $output = file_get_contents($url); // try to convert the response into a PHP object $obj = json_decode($output); if(!is_object($obj)) die("Error parsing JSON response\n"); //define variables $avatar = ($obj->user->avatar); $gold = ($obj->user->gold); print $avatar; print $gold; ?> if you print_r $object; it displays this {"error":{"code":200,"desc":"OK"}},{"user":{"gold":1,"gamertag":"l RaH l","avatar":"http:\/\/avatar.xboxlive.com\/avatar\/l%20RaH%20l\/avatarpic-l.png","gamerscore":12508,"reputation":20},"recent_games":[{"recent_game":{"title":"Halo: Reach","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1297287259&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/ih\/ew\/0Wdsb2JhbA9ECgR8GgMfVlohL2ljb24vMC84MDAwIAAAAAAAAP6fF5U=.jpg"}},{"recent_game":{"title":"Halo 3","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1297287142&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/Us\/3e\/1Wdsb2JhbA9ECgR8GgMfWSpVL2ljb24vMC84MDAwIAAAAAAAAPrxzU0=.jpg"}},{"recent_game":{"title":"AC Brotherhood","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1431504989&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/oK\/tp\/1Wdsb2JhbA9ECgUNGgMfVlonL2ljb24vMC84MDAwIAAAAAAAAPpGq78=.jpg"}},{"recent_game":{"title":"Fighters Uncaged","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1431504974&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/v+\/Au\/0Wdsb2JhbA9ECgUNGgMfVlsmL2ljb24vMC84MDAwIAAAAAAAAP4B4KA=.jpg"}},{"recent_game":{"title":"Assassin's Creed","link":"http:\/\/gamercard.xbox.com\/en-US\/GameCenter\/Achievements?titleId=1431504852&compareTo=l%20RaH%20l","image":"http:\/\/tiles.xbox.com\/tiles\/L3\/mu\/0Wdsb2JhbA9ECgUNGgMfWStXL2ljb24vMC84MDAwIAAAAAAAAP6BeTA=.jpg"}}]} Hey guys I am Posting data over to a server file in Json and I need to know how I can add to the XML file. here is both codes.
function validate() { $xml = simplexml_load_file("stock.xml"); $sxe = new SimpleXMLElement($xml->asXML()); for($i = 1; $i < 801; $i++) { $newItem->addChild("name" , "null"); } $sxe->asXML("stock.xml"); echo $sxe->asXML(); $response = $_POST; $response["items"] = "Test output"; $response["description"] = "test 42 "; $response["json"] = json_encode($response); echo json_encode($response); }The red text is what I want this json script to do. Do I have to return back to my form to add to the XML file? Can json add to a xml file on its own? Thanks for your time! have a good day! Hi, I have two select boxes on my site like this: Language - Level and the user can keep adding more sets of select boxes. I need the data posted to be JSON encoded like this: {"LANG1":["German","Beginner"],"LANG2":["Polish","Advanced"]} etc How can i make this happen? Hello, I can't get a json call to work in my php... Hope some one can see where I am going wrong and push me in the right direction. I have 3 values I am trying to send from the php file to the html. The output looks as if it should work, but is does not... So here is the php variable that does give me a result, but I have no idea why it does not show in the div. <?php $choice = (isset($_POST['choice'])) ? date("Y-m-d",strtotime($_POST['choice'])) : date("Y-m-d"); $con = mysql_connect("localhost","root","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 = '".$choice."' group by date"; $res = mysql_query($sql) or die('sql='.$sql."\n".mysql_error()); $row = mysql_fetch_assoc($res); $dayPowerP = array( $row['choice']); ?> <?php $choice = (isset($_POST['choice'])) ? date("m",strtotime($_POST['choice'])) : date("m"); $con = mysql_connect("localhost","root","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); $monthPowerP = array($row['choice']); ?> <?php $choice = (isset($_POST['choice'])) ? date("Y",strtotime($_POST['choice'])) : date("Y"); $con = mysql_connect("localhost","root","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); $yearPowerP = array( $row['choice']); ?> <?php $outarr['dayPowerP'] = $dayPowerP; $outarr['monthPowerP'] = $monthPowerP; $outarr['yearPowerP'] = $yearPowerP; echo json_encode($outarr); ?> Now there are no errors, and this is what the output is so I would assume it should work as the right values are there and the right id..... Code: [Select] {"dayPowerP":["12.7240"],"monthPowerP":["145.0460"],"yearPowerP":["941.0370"]} I do not understand. Now the Jquery should be working as well... the ajax should be sending the post with json to carry the key data to make a clear result from the php and json should be doing it's job in the php file and the Jquery is do basic to have any issues, so that leaves my focus on the PHP at this time, but I do not see a proplem. Code: [Select] $(document).ready(function () { $('#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)); $.ajax({ type: "POST", url: "clickdates.php", data: {choice: dateText}, dataType: "json", success: function(json_data) { $('#apDiv2').html(json_data['dayPowerP']); $('#apDiv6').html(json_data['monthPowerP']); $('#apDiv8').html(json_data['yearPowerP']); } }) }}); }); The one thing that is odd. When I use 3 different php files, it works perfect, but that is not using json. Now that I am using json to return 1 call from the php, I am lost at this point, does anyone see what I can't... Thanks, Alan im trying to access code in Code: [Select] array(1) { [0]=> object(stdClass)#4 (1) { ["error"]=> array(1) { [0]=> object(stdClass)#5 (2) { ["message"]=> string(33) "no results found (error code 458)" ["code"]=> string(3) "458" } } } } ive tryed echo $blog_posts[0]->error->code; but all i get is Notice: Trying to get property of non-object in /home/sites/inspiredanceacademy.com/public_html/sno-blog-test/lib/social_news_office.php on line 173 Okay so i know this is going to sound really stupid i just got out of school and now im in the real world here is the problem I dont know very much about how to work with JSON via PHP all i am trying to do is have the Script read data into an array from some text boxes then from the array into a JSON file the reading and the listing is all fine and dandy but only if i want the entire file how do i read data from a JSON file and only have it display data according to what i want so for example if i wanted to return data that matched an ID like you would do in MySQL like this ("SELECT * FROM catagories WHERE ID = '$id'") so how do i do that without a Database using a JSON File as a source for the data Please see http://www.socialnewsoffice.com/blog_posts?&display=2&api_key=b5cbd66dca99c49d1a6c3d which out puts a json response like this Code: [Select] [{ "blog_id":"3", "post_date":"Sat, 14 April 2012", "post_title":"Facebook's New Fan Page Learn How To Use Features", "article_img":"http:\/\/www.socialnewsoffice.com\/uploads\/17963.jpg", "post_content":"<p>This week saw the release of Facebook's latest functionality changes (Timeline for Businesses) that will shape the future of how businesses will market their campaigns, through the social media giant Facebook. A number of marketers are wondering how they will incorporate the new features in an attempt to progress and move forward with their online social media presence.<\/p>\r\n<p>Taking all the key changes in to consideration we have managed to create a guide on how to smoothly move with the times and embrace the new Facebook layout.<\/p>\r\n<p>Please read on below for helpful tips and tricks on how to excel with 'Timeline for Brands'<\/p>\r\n<h2>New Features Announced at the Facebook Marketing Conference:<\/h2>\r\n<p><strong>View and Apps:<\/strong> What was once known as Application pages has changed to 'Tabs'. These can now have customizable images linked with them and the order of them can be changed too. Below you can see from the screenshot what a customized Facebook Timeline looks like.<\/p>\r\n<p><strong>Pinning Content:<\/strong> With this new feature you can 'pin' a post to the very top of your Facebook Timeline. This is Very effective when working on a new campaign and is a great way to entice increased traffic to your tab or application page.<\/p>\r\n<p><strong>Featured 'Starred' Content:<\/strong> This feature allows you to select key content or imagery and extend it so it fits across your entire page. Therefore giving you featured content on your Facebook Timeline and making it more visible.<\/p>\r\n<p><strong>Cover Photos:<\/strong> Cover Photos are another great new feature that allow you to announce your latest campaign, welcome your following community or just simply show visitors to your timeline what you can do. There are some slight flaws with this feature though and will be addressed below.<\/p>\r\n<p><strong>Page Dimensions:<\/strong> Dimensions of application pages has now changed with the release of Facebook Timeline. If you happen to be an SML user then you have all the tools necessary to update your page on your own. If your using Involvers App Suite then those applications will be updated soon.<\/p>\r\n<p><strong>Removal of Default Landing Pages:<\/strong> The commonly used Facebook landing pages have been removed and replaced with various options to allow brands to drive content to application pages. These options allow you to use your cover photo and pinned content to attract users to your personal application pages. Despite the changes it is however still possible to link directly to application pages from ads, posts and outside of Facebook.<\/p>\r\n<h2>Getting Started with Timeline For Brand:<\/h2>\r\n<p>Firstly when accessing and logging in to your New Facebook Brand Page, you will see this admin message displayed below:<\/p>\r\n<p>When will my Page change to the latest design?<\/p>\r\n<p>To see a preview of what your new pages will look like, simply click on the green button at the top of your current pages. A second option is to wait until March 30th 2012 when all pages will be upgraded automatically.<\/p>\r\n<p>Where can I visit to learn more about how to use the new Pages?<\/p>\r\n<p><strong>There are a number of places you can visit to learn all you need to know about Pages:<\/strong><\/p>\r\n<ul>\r\n<li>To find out more about new features, download the Pages Overview guide by clicking here.<\/li>\r\n<li>If your wondering how to get started with Pages then download Facebook's full Pages Product Guide by clicking here.<\/li>\r\n<li>The Pages Learning video allows you to walk through the key features with Facebook's product experts.<\/li>\r\n<li>If you need answers to specific questions, visit Facebook's Help Centre.<\/li>\r\n<\/ul>\r\n<h2>How should I choose a cover photo for my Page?<\/h2>\r\n<p>Firstly select a unique image that represents your page. Facebook itself recommends using a photo of a popular menu item, album artwork or an image of your product being used by someone. You need to experiment with a number of different images that your audience responds positively to. Few key elements of Cover Images:<\/p>\r\n<p><strong>Each Cover image must be at least 399 pixels wide and must not contain the following:<\/strong><\/p>\r\n<ul>\r\n<li>Prices \/ Purchase information and displaying offers such as \"60% off this month\" are not permitted. Also 'Download this from our website' is not allowed.<\/li>\r\n<li>No email addresses, web addresses and any other contact information.<\/li>\r\n<li>References to clicking on or the use of Facebook interface elements such as Like or Share or any other Facebook Features.<\/li>\r\n<li>\"Tell your friends\" or \"Get it now\" or any other calls to action are not allowed in the latest version of Facebook Timeline.<\/li>\r\n<\/ul>\r\n<p>All Timeline cover imagery is public and therefore means anyone visiting your Page will be able to see exactly which image you have chosen. The photos you display must not be deceptive, false or misleading any way that infringes on third party intellectual property. You must also not encourage of incentivize other fellow users, friends or business associates to display the same cover image as yours on personal Timelines.<\/p>\r\n<p>To sum up we are extremely excited about the latest Facebook feature release this week. They constantly deliver new services that are amazing and incredibly innovative to the market place.<\/p>\r\n<p>Here at Northplanet we are commited to provide you with the latest information on the hottest online topics around, to keep you ahead in the game. We would love to hear some feedback from you on the brand new Facebook 'Timeline for Brands' release and invite you to visit our very own <a href=\"https:\/\/www.facebook.com\/northplanet\">Northplanet Facebook Timline page by clicking here.<\/a><\/p>", "tags":"facebook, new fan page", "views":"463", "categorie_id":"2", "post_url":"facebooks-new-fan-page-learn-how-to-use-features" },{ "blog_id":"2", "post_date":"Mon, 23 January 2012", "post_title":"Northplanet Engages New Talent!", "article_img":"http:\/\/www.socialnewsoffice.com\/uploads\/1263.jpg", "post_content":"<p>Big piece of news for the start of 2012 is…… I have landed a full time role in a leading Web Design and Development agency based in Greater Manchester. After a successful interview on New Years Eve, I had another reason to celebrate bringing in the New Year!!<\/p>\r\n<p>I was first attracted to Northplanet when I came across there website when searching for jobs online. I was impressed not only by the standard of web work but the direction the company where going in. Growing year by year and providing exceptional web solutions for a number of businesses spread across the UK.<\/p>\r\n<p>I contacted them instantly and have done some freelance work a few times in the last year for Directors Danny and Mike and was able to build up a strong working relationship that helped me land the interview at the end of the year.<\/p>\r\n<p>I begin my career at Northplanet next week and will post all offers\/promotions and deals on here in the nearfuture.<\/p>\r\n<p>Time to sign off and prepare for my new career!!<\/p>", "tags":"engages new talent, new staff, northplanet staff, christian thomas mizon", "views":"271", "categorie_id":"1", "post_url":"northplanet-engages-new-talent" }] here is my code that does this Code: [Select] if (mysqli_num_rows($r) > 0) { // Available. while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $results[] = array( 'blog_id' => ($row['ID']), 'post_date' => ($row['pd']), 'post_title' => (html_entity_decode($row['post_title'], ENT_QUOTES)), 'article_img' => ('http://www.socialnewsoffice.com/uploads/'.$row['article_img']), 'post_content' => ($row['post_content']), 'tags' => ($row['tags']), 'views' => ($row['views']), 'categorie_id' => ($row['categorie_id']), 'post_url' => ($row['post_url'])); } echo $json = Pretty_JSON(json_encode($results)); } i can access the json by using foreach($blog_posts as $post) { however what i need to do is add a value to the json like pages => 2 how could i do this? Hello
This may seem like a silly question but if you never ask you never know...
Lets say I json encode a php array. When I echo out the encoded json string into a JS variable it looks something like this in the resultant markup:
var arr = ["cow - Copy (10).jpg","cow - Copy (2).jpg"];So in this instance the string I've echoed out is equivalent to a JS array and I can use it straight away. My questions: 1) Is it valid to do what I've done above? 2) Since I can use the array right away is there any need to JSON.parse? 3) When would you use JSON.parse? Thanks, Drongo im trying to get this ajax function working but for some reason it runs the error function...I've corresponded with the manual and I can't see a fault...any advise would be great...thanks
$(document).ready(function() { $.ajax( { url: "items.php", dataType: "json", data: '<?php echo $data; ?>', timeout: '2000', cache: false, error: function(data) { alert('error'); }, success: function(data) { $.each(data, function() { $("#table").append('<div class="row"><span class="cell">'+ data.title +'</span><span class="cell"></span><span class="cell"></span></div>'); }); } }); }); |