While playing with the code today, I found an interesting benefit of using back ticks in the table name in mysql query.
I created a table in my database as “abc.test” and added some dummy data to the table as shown in below screenshot.
Now with a simple mysql_query I was trying to fetch the data but its returning nothing, after a check I found that i missed those back ticks from my table name.
Incorrect Query (without back ticks)
mysql_query(“SELECT * FROM abc.test”);
Correct Query (with back ticks)
mysql_query(“SELECT * FROM `abc.test`”);
My whole working php code, to fetch data –
$conn = mysql_connect('localhost','root','');
die('Could not connect: ' . mysql_error());
$result = mysql_query("SELECT * FROM `abc.test`");
while ($row = mysql_fetch_assoc($result) )
echo "Id is : ".$row['id']." "." Name is : ".$row['name'];
echo and print are both language construct in php, however print returns 1 but it is not a function.
Below mentioned usage of echo and print, both are valid –
echo "Hello World"
print "Hello World"
echo can output more than 1 string while print cannot(using comma separator)
echo "Hello", "world","I am Swapnesh";
$postData['offemail'] = 'firstname.lastname@example.org';
$templateId = 1;
$recipients = Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT);
$recipients = explode(',' , $recipients);
$store = Mage::app()->getStore();
$translate = Mage::getSingleton('core/translate');
array('data' => $postObject),
MySQL Server doesn’t support the SELECT to make table backup, so this query is not going to work in phpmyadmin –
However to take table backup, run this query –
CREATE TABLE default_table_backup_31_08_2012 SELECT * FROM default_table;
This is my table structure, and my aim is to fetch data from the single table in parent -> child -> parent manner —
MY Query —-
And Finally, my RESULT —
System.out.print is totally valid in php likewise in JAVA. I ran this sample code and its working all fine in PHP 5.3.
$result = 5;
System.out.print(“This is a valid System.out.print with uppercase S”);
system.out.print(“This is a valid system.out.print with lowercase s”);