cereal 1,524 Nearly a Senior Poster Featured Poster

So you don't save images names to database? In that case just check last inserted ID for that gallery. Anyway, I prefer glob to scandir:

<?php
# glob sorts only by alphabetic order, GLOB_NOSORT flag speeds up the function
$list = glob("{*.jpg,*.gif,*.png}",GLOB_BRACE|GLOB_NOSORT);
array_multisort(array_map('filemtime', $list), SORT_DESC, $list);
echo $list[0]; # get last modify time
?>

When you run stat, into a command line, to a file you get 3 different dates:

Access: 2012-01-19 00:56:04.104197718 +0100
Modify: 2012-01-13 15:54:58.000000000 +0100
Change: 2012-01-23 12:22:36.672104877 +0100

You can use fileatime, filemtime and filectime functions to get those values: each time you open an image or use touch command Access time is changed (fileatime); each time the inode information of the file is modified, like renaming, moving the file, setting new permissions the Change time is modified (filectime); last, each time the contents of a file is updated Modify time changes, so this function should be the most important for you: filemtime.

More info: http://php.net/manual/en/function.filemtime.php
Hope is helpful, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

This article is a good start: http://devzone.zend.com/1254/getting-started-with-openid-and-php/

I did it once, for a project in which I adopted Janrain solution (most because I could not use the PEAR package): http://www.janrain.com/
This plugin remembers the user (even after logout) and when he comes back gives a suggestion.

In that project, users had the ability to create a standard account or to log with an available OpenID (Flickr, Twitter, Yahoo, Google, Windows Live and MySpace).

If that was first login from openID and there was no match with a standard accounts, then it was created a new account. Otherwise, the user was suggested to merge it with the matched account. Anyway, if the user had also a standard account he had the ability to merge the account.

A (requested) nightmare :S

Virtually, in that project, a user can login with many OpenIDs and link always to the same standard account.

To fully enable an account created with an OpenID, it was requested to complete the login inserting an email, usually from the OpenId service you get enough data but sometimes, as with Twitter, you don't get any email address. So, for this reason, it was requested.

Once you have an email and the user choose to login with Facebook and Twitter and Google and whatever else, when he completes with the same email you can merge the accounts..

I repeat: a requested nightmare :'(

Anyway, if you want …

diafol commented: great reply, as usual :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster
<?php
$brush_price = 5;
$quantity = 10;
$total = $brush_price * $quantity;
echo "<table border=\"1\" align=\"center\">
<tr><td>Quantity</td><td>Price</td></tr>
<tr><td>$quantity</td><td>$total</td></tr>";
?>

Bye.

Farhad.idrees commented: 1 +3
cereal 1,524 Nearly a Senior Poster Featured Poster

Just another version :P

<?php
$a = array('/st/','/nd/','/rd/','/th/');
echo preg_replace($a,'<sup>$0</sup>',date('dS F Y'));
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

Are you using a database or is just a directory?
If only a directory (images) and no database registration you can use glob():

<?php
# GLOB_NOSORT flag will help to go a bit faster
$a = glob('a_*.jpg',GLOB_NOSORT);
$b = glob('b_*.jpg',GLOB_NOSORT);

echo count($a) . " " . count($b);
?>

This can work by using a prefix for each category (like a_ and b_), but it can become slow if you start to have thousands of images. To limit reads on filesystem you can create a text file where you store a bidimensional array with categories and filenames, you can also store this information to memory with memcached. It's up to your needings.

edit: you can also consider scandir()* which is faster than glob() but available only with PHP5.

* http://php.net/manual/en/function.scandir.php

diafol commented: I like glob too :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

Add a loop:

$Families = array ( "Farhad" =>array("Ali","Haider","Kashan"), "Sufyan" => array("Shahbaz","Ali2","Azaan"));
 
foreach($Families as $key2=>$values3)
{
        foreach($values3 as $v)
        {
            echo "$key2 $v";
        {
}

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

In report.php class, line 94 you echo inside the class but you should use return:

return $employee_id; #last id of multiple insert

In same function you should set a mysql_query() in order to insert. But it seems you want to send groups of arrays, reordered by report.php view, but there is something wrong, when you write:

$report->request_date[$i] = $_POST["request_date"];

you are not considering that multiple values are set under request_date (and also the others fields of the form), try to simply print_r() that variable: <?php print_r($_POST['request_date']); ?> and you will see an array with a value for each report form, so if there are three reports you will have three request_date values. At the moment you get six different arrays from your form and you need to create a single array, like in this example:

<html>
<head><title></title></head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
        print_r($_POST['a']);
        echo "<br />";
        print_r($_POST['b']);

        $neworder = '';
        $c = count($_POST['a']);
        for($i = 0; $i < $c; $i++)
        {
                $neworder[] = array($_POST['a'][$i],$_POST['b'][$i]);
        }
        echo "<br /><pre>";
        print_r($neworder);
        echo "<pre>";
}
?>
<form method="post" action="">
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
<br />
a: <input type="text" name="a[]" />
b: <input type="text" name="b[]" />
<br />
<input type="submit" name="button" value="submit" />
</form>
</body>
</html>

The output:

Array ( [0] => a [1] => aa ) # first report
Array ( [0] => b [1] => bb ) # last report

# single array
Array
(
    [0] => Array
        (
            [0] => a
            [1] => b …
socialmd commented: Informative, shed light on flaw in code, and explained process very well +0
cereal 1,524 Nearly a Senior Poster Featured Poster

Change addslashes() with mysql_real_escape_string() at line 16.
But you should also move file somewhere else with move_uploaded_file() and check for mime-type match. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Why all those quotes? Rewrite your statements:

if($_POST['type_id'] == FALSE && $_POST['location_id'] > 0 && $_POST['bedroom_id'] > 0 && $_POST['price_id'] > 0)
manc1976 commented: Thanks for showing me a better way to write this code +1
cereal 1,524 Nearly a Senior Poster Featured Poster

Why don't you set a random password and send that to the user via email? That way the user will change it after he logs to his own profile.

cereal 1,524 Nearly a Senior Poster Featured Poster

^^ I tried media, thumbnail, media:thumbnail and every other possibility already lol. didn't work and that's why I asked again

use my code posted above, without changing anything, is tested and works, in this case you don't have to set a namespace because we are using getElementsByTagNameNS() which needs just the namespace URI for media, which, in your case, is http://search.yahoo.com/mrss/

So, for completeness:

<?php
$xml="http://feeds.bbci.co.uk/news/rss.xml";
$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);
$i = $xmlDoc->getElementsByTagNameNS('http://search.yahoo.com/mrss/','thumbnail');
echo $i->item(0)->getAttribute('url');
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

Yes:

<input type="radio" name="button1" value="On" onClick="submit();" <?php echo ($_POST['button1'] == 'On') ? 'checked="checked"' : ''; ?> /> On
	<input type="radio" name="button1" value="Off" onClick="submit();" <?php echo ($_POST['button1'] == 'Off') ? 'checked="checked"' : ''; ?> /> Off

bye!

Xufyan commented: thanku xufyan +3
cereal 1,524 Nearly a Senior Poster Featured Poster

Just a note, you can go a bit faster changing numbers with variables, a modified version of mikulucky:

<?php
$a = 0;
$b = 1;
$c = 2;
$d = 3;
$endAmount = 100000;

for ($i = $a; $i <= $endAmount; $i++) 
{

    if($i % $c != $b) 
    {
      continue;
    }

    $x = sqrt($i);

    while ($i % $d != $a && $d < $x)
    {
        $d += $b; 
    }

    if((($i % $d == $a && $i != $d) * $b) == $a) 
    {
	echo $i . " ";
    }
 }
?>
cereal 1,524 Nearly a Senior Poster Featured Poster

happy new year! :)

cereal 1,524 Nearly a Senior Poster Featured Poster

From substr() manual:

string substr ( string $string , int $start [, int $length ] )
If length is given and is 0, FALSE or NULL an empty string will be returned.

The problem is related to substr() on line 6, because strrpos() returns FALSE when there are no spaces:

$string = substr($string, 0, strrpos($string, ' '));

therefore you have substr('nospacestring',0,false) In order to solve change that line with this, which makes use of ctype_space():

if(ctype_space($string))
{
   $string = substr($string, 0, strrpos($string, ' '));
}

bye :)

dean8710 commented: tq dude +2
cereal 1,524 Nearly a Senior Poster Featured Poster

Man, change your database password!

phorce commented: Bravo! +3
cereal 1,524 Nearly a Senior Poster Featured Poster

Check the headers you get with that link:

<?php
$url = 'http://user:pwd@xyz.com/content.html?get1=x&get2=y';
print_r(get_headers($url,1));
?>

And then try to use cURL:

$useragent = "Mozilla Firefox ..."; # set valid user agent
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

There can be a filter for nonvalid user agents. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

The platforms supported by ffmpeg-php are linux and bsd: http://sourceforge.net/projects/ffmpeg-php/
If you want to use ffmpeg in Windows first you need a porting, check here: http://ffmpeg.org/download.html

And then you can use ffmpeg in command line, with exec() function:

<?php exec("ffmpeg.exe -i video.avi video.mpg"); ?>

bye

cereal 1,524 Nearly a Senior Poster Featured Poster

Both RSS 2.0 and Atom use GUID and ID to identify unique items/entries inside the feed, use those values associated with each source to check what you have already included.

Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Quick suggestion: when login is true I prefer to set a session which enables users rights. So, at least, I can stop bugging the database for that. Otherwise I will have an extra query for each reserved page and each user logged. Bye :)

diafol commented: agreed +14
cereal 1,524 Nearly a Senior Poster Featured Poster

A variable cannot start with a number, you have to use an alphabetic character instead, so $0 and $1 are wrong. For example use $a0 and $a1.

Anyway, in your case a bi-dimensional array can be written as below:

$a = array(
 array(40,60,20),
 array(278,102,173)
);

To display data, then write:

echo $a[0][1]; # will display 60

If you want to assign specific keys you can write:

$a = array(
'alfa' => array(40,60,20),
'beta' => array(278,102,173)
);

echo $a['alfa'][2]; # output 20

bye.

Zagga commented: Nicely explained +5
cereal 1,524 Nearly a Senior Poster Featured Poster

The problem is related to the double quotes, rewrite that line 19:

$img = $info['photo'];
echo '<img width="240" height="240" alt="Wonky Buildings"  src="images/'. $img .'>';

Or:

echo "<img width=\"240\" height=\"240\" alt=\"Wonky Buildings\" src=\"images/".$img ."\">";

Or:

echo "<img width='240' height='240' alt='Wonky Buildings' src='images/$img'>";

bye

cereal 1,524 Nearly a Senior Poster Featured Poster

In both you need to use mysql_query:

$query=mysql_query($sql);
qazplm114477 commented: that's exactly it +5
cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Ok, but lets try to simplify the problem, in your example code there are no form tags, so you can't send data to the server. In the code you wrote here the problem is not PHP (which is not included) but the HTML part. You need something like this:

<form method="post" action="page.php">
<input type="text" name="first_name" />
<input type="submit" name="button" value="send data" />
</form>

And basically in page.php you need:

<?php
echo $_POST['first_name'];
?>

So: you need to give name or id to input fields, and you need to enclose all your input fields between form tags.

cereal 1,524 Nearly a Senior Poster Featured Poster

An alternative solution: use filectime(), each file saves 3 different dates: created, modified and access, with touch() or file_put_contents() you can change "modified" date without changing contents. Here is an example:

<?php
$a = glob('*.jpg', GLOB_NOSORT);
$b = array();
print_r($a); # all images
for($i = 0; $i < count($a); $i++)
{
    $time = filectime($a[$i]);
    $b[$time] = $a[$i];
}

$mx = max(array_keys($b));
$mn = min(array_keys($b));

if((time() - $mx) < 3) # at moment 3 seconds, 1800 = 30 minutes
{
    echo 'visible: ' . $b[$mx] . "\n";
}
else
{
    echo 'new: ' . $b[$mn];
    touch($b[$mn]); # update "inode change time"
}
echo "\n";
?>

In order to work you need to change the "modified" date to each image, you can run this script right before you start the above one:

<?php
$a = glob('*.jpg',GLOB_NOSORT); # remove second parameter to sort files
for($i = 0; $i < count($a); $i++)
{
     touch($a[$i]);
     sleep(2);
}
?>

After this, if you don't modify the images there will be always the same order. Every time the page is loaded the script will check for the latest updated "modified" date and if the difference between this value and the current time is higher than 30 minutes (3 seconds in my example) it will update the file with the oldest time, and so on, in loop.
bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Use floor() or ceil(), floor will output 12 no matter if it is 12,2 or 12,9, ceil is different, since 12,51 will output 13 instead of 12.

$filesize=floor($size/1000000);
cereal 1,524 Nearly a Senior Poster Featured Poster

Hm, with null/false/-1/'' as value you can display the array:

$a = array('a' => false, 'b' => '', 'c' => '1a');
print_r($a);

Just make sure to not run array_filter() against this array or those will be removed.

vedro-compota commented: +++++++++++ +3
cereal 1,524 Nearly a Senior Poster Featured Poster

Try:

<?php
echo date('Y-m-d- G:i:s'); # systme
date_default_timezone_set("GMT");
echo date('Y-m-d- G:i:s'); # GMT
?>
diafol commented: :) +14
cereal 1,524 Nearly a Senior Poster Featured Poster

This should work:

<?php
# ...
# connection code
# ...

$q = mysql_query('select defect_code, total from grandTotal');
$a = array();
while($row = mysql_fetch_object($q))
{
    $a[$row->defect_code] = $row->total;
}

print_r($a); # display array
?>

bye :)

ooops ardav, I just saw your reply, sorry.. :D

cereal 1,524 Nearly a Senior Poster Featured Poster

According to adobe livedocs:

When you define variables within the URLVariables constructor or within the URLVariables.decode() method, you need to make sure that you URL-encode the ampersand character because it has a special meaning and acts as a delimiter. For example, when you pass an ampersand, you need to URL-encode the ampersand by changing it from & to %26 because the ampersand acts as a delimiter for parameters.

So if your link is something like this:

http://a_server/a directory/page.php&id=1

You have to change it to:

http://a_server/a%20directory/page.php%26id=1

You can easily use urlencode() to create those links: http://php.net/manual/en/function.urlencode.php
Hope is useful, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Try add the url to the URLRequest:

var myRequest:URLRequest = new URLRequest("http:/your_server/test.php");

bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

You can see other entries by using mysql_data_seek(): http://www.php.net/manual/en/function.mysql-data-seek.php
When using while() with mysql_fetch_array() there will be a move of the internal row pointer for the query result, so it moves from one key to another, automatically:

<?php
$result = mysql_query("SELECT * FROM post_categories");
$row = mysql_fetch_array($result);
echo $row['Name'];
print_r($row);

mysql_data_seek($result, 1);
$row = mysql_fetch_array($result);
print_r($row);

mysql_data_seek($result, 2);
$row = mysql_fetch_array($result);
print_r($row);
?>

bye :)

note: using mysql_fetch_array() you will end up with an array with both numerical and field name keys, if you use mysql_fetch_assoc() you will get just the table field names.

Martin C++ commented: Thanks for good answer +1
cereal 1,524 Nearly a Senior Poster Featured Poster

imo the best exercise is to try to solve problems here in the forum ;)

cereal 1,524 Nearly a Senior Poster Featured Poster

I never tried that but it's interesting how, in ez_sql_core.php, he writes cache to disk, he is using error_log(), but as stated in error_log() function page: the maximum length that you can pass as the $message is limited by log_errors_max_len, which is 1024 bytes by default in php.ini. So, if you want to use ezsql you can:

1. increase that limit
2. use igbinary_serialize() & igbinary_unserialize() which occupies less space when serializing a string and is also faster than the current php serialize()/unserialize()

igbinary: http://opensource.dynamoid.com/
error_log: http://php.net/manual/en/function.error-log.php

bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe I'm wrong but searching on web I came up with a thread discussing of that obfuscated js code, and it seems to match an injection attack, here's the link:

- http://www.reddit.com/r/javascript/comments/mk1u8/i_found_code_in_my_files_i_did_not_add_what_does/c31jt8k

cereal 1,524 Nearly a Senior Poster Featured Poster

Have you tried explain? For example:

mysql> explain users;
+---------+-------------+------+-----+---------+----------------+
| Field   | Type        | Null | Key | Default | Extra          |
+---------+-------------+------+-----+---------+----------------+
| id      | int(9)      | NO   | PRI | NULL    | auto_increment |
| fname   | varchar(50) | NO   |     | NULL    |                |
| lname   | varchar(50) | NO   |     | NULL    |                |
| userid  | varchar(50) | NO   |     | NULL    |                |
| referer | varchar(50) | NO   |     | NULL    |                |
+---------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

You can also use show create table users\G that will output additional data:

mysql> show create table users\G
*************************** 1. row ***************************
       Table: users
Create Table: CREATE TABLE `users` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `fname` varchar(50) NOT NULL,
  `lname` varchar(50) NOT NULL,
  `userid` varchar(50) NOT NULL,
  `referer` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
cereal 1,524 Nearly a Senior Poster Featured Poster

First of all remember to use CODE to wrap data you post in the forums.
Second: this is wrong $this->db->select('id','country_name'); you should write $this->db->select('id, country_name'); otherwise country_name will be seen as second argument.

Check if this solves the problems. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

The allowed input types are:

button
checkbox
file
hidden
image
password
radio
reset
submit
text

you are using type="input" since line 48, change it and it should work. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

Change that query to:

$result = mysql_query("SELECT * FROM customers WHERE customerID = '$customerID'") or die(mysql_error());

If there is a problem you will get the error, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Something like this should work, where the name has the format status_"id_user": status_1, status_2 ... status_23.

<input type="radio" name="status_1" value="to be" /> to be
<input type="radio" name="status_1" value="not to be" /> not to be

<input type="radio" name="status_2" value="to be" /> to be
<input type="radio" name="status_2" value="not to be" /> not to be

<input type="radio" name="status_3" value="to be" /> to be
<input type="radio" name="status_3" value="not to be" /> not to be

This will give you:
$_POST
$_POST
$_POST

Then use array_keys to extract user ids, you will end up with something similar to this:

<?php
$a = array_keys($_POST);
$array = array();
foreach($a as $key)
{
	if(preg_match('/status/i',$key))
	{
		$b = explode('_',$key);
		echo 'id: ' . $b[1] . ' value: ' . $_POST[$key];
		
		# uncomment below to build an array
		# $array[] = array($b[1] => $_POST[$key]);
	}
}

#print_r($array);
?>

hope it's useful, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

This is called Method Chaining and yes, you can use it whenever you want if the class is built in the right way. Check this comment on PHP Manual: http://www.php.net/manual/en/language.operators.php#87904
bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

Together with pritaeas suggest, you can also append a random string to the end of the file:

<a href="/path/file.txt?random_string">file name</a>

you won't need that value to open the file and the browser will read always a new link.

cereal 1,524 Nearly a Senior Poster Featured Poster

Remove center and font tag and write:

<a style="display: block; width: 100px; height: 30px; margin: 20px auto; color: white" href="../index.html" border=0>Back To Menu</a>

Otherwise use a div:

<div style="width: 800px; margin: 20px auto; text-align:center;">
<a style="color:left;" href="../index.html" border=0>Back To Menu</a>
</div>

You can use also float to do this.

cereal 1,524 Nearly a Senior Poster Featured Poster

Remove select tags and change line 16 to this:

echo "<input type='checkbox' name='horse_id[]' value='$horse_id' /> $horse_name (#$horse_id), $breed\n";

This will give you an array, if then you need to select from the database you can use implode() from PHP and in() from MySQL to do a single query:

$a = implode(',',$_POST['horse_id']);
$query = "select * from horses where id in ($a)";

Credits to ardav :)

diafol commented: too kind cereal! :) +13
cereal 1,524 Nearly a Senior Poster Featured Poster

Did you tried this?

mysql -uCHRIS -pCHRISSEC
cereal 1,524 Nearly a Senior Poster Featured Poster

You can get something similar to your desired output with this script:

<?php
$a = array(array(array('name' => 'praveen','id' => '20'),array('name' => 'kumar','id' => '25')));
$b = array(array(array('name' => 'pandu','id' => '21'),array('name' => 'praveen','id' => '30')));
$c = array_merge($a,$b);
$arr = count($c);

for($i = 0; $i < $arr; $i++)
{
	foreach($a as $key => $value)
	{
	    $q1[$value[$i]['name']] = array('id' => $value[$i]['id']);
	}
	
	foreach($b as $key => $value)
	{
            $q2[$value[$i]['name']] = array('id' => $value[$i]['id']);
	}
}
print_r(array_merge_recursive($q1,$q2));
?>

The output will be:

Array
(
    [praveen] => Array
        (
            [id] => Array
                (
                    [0] => 20
                    [1] => 30
                )
        )

    [kumar] => Array
        (
            [id] => 25
        )

    [pandu] => Array
        (
            [id] => 21
        )
)

As you can see, instead of id1, id2, you will get an id array. Bye :)

diafol commented: Nice - couldn't get my head around this one - like the array_merge_recursive +13
praveen_dusari commented: excellent answer... +5
cereal 1,524 Nearly a Senior Poster Featured Poster

If you remove print_r() from line 64 and write $result, you can do this:

$result = array_merge_recursive($m2,$a4);
$q = '';
foreach($result as $key => $value)
{
	$name = trim($name);
	$location = trim($key);
	$utc = str_replace("\n",'',$utc);
	$coma = (empty($q)) ? '':',';
	$q .= "$coma values('$name', '$location', '$value[0]', '$utc', '$value[1]', '$value[2]', '$value[3]', current_timestamp())";
}

echo "INSERT INTO wetteroe (name, location, height, utc, temp, humidity, wind, DATEtime) $q"; #

This will give you two big inserts, basing on the names: Vorarlberg and Tirol.
I would use three tables, not only one: the first for the names, another for the locations and one for height, temp, humidity, wind and pressure. But that's just my opinion. Bye :)

Just a tip on previous code, online 4 and 5 I wrote:

$s = '1';
for( $i=0; $i<=$s; $i++){

The correct version is:

$s = count($arr);
for( $i=0; $i<$s; $i++){

Without equal ^__^'

cereal 1,524 Nearly a Senior Poster Featured Poster

Maybe there's something wrong, to me that JSON doesn't seems to have two blocks. You could do something like this:

{
"first block":
    {
    "name":"value 1",
    "location":"value 2"
    },
"second block":
    {
    "name":"value 1",
    "location":"value 2"
    }
}

And in the PHP part:

<?php
$f = file_get_contents('j.json');
$j = json_decode($f,true);
echo $j['first block']['name'] . "\n";
echo $j['first block']['location'] . "\n";
echo $j['second block']['name'] . "\n";
echo $j['second block']['location'] . "\n";
?>

Hope it helps, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

And also your table name, return, is a reserved word, check this: http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
Use backticks if you want to use it:

"insert into `return` ..."

bye :)

karthik_ppts commented: Yes. +6