Checking the passing data array ( Debugging at the PHP and Javascript )

PHP Page တစ္ခုေရးတဲ႕ အခါ Database ထဲကေန Select ယူလုိက္တဲ႕ Data ေတြကို ဘယ္လုိပါလာသလဲ သိခ်င္သည္႔ အခါ ….
print_r(array_name);  Or echo var_dump(array_name);

အေနနဲ႕ ထုတ္ယူၿကည္႔ရႈႏုိင္ပါသည္ …..

print_r(array_name);  Or echo var_dump(array_name);  ေရးၿပီးသည္႔ အခါ
exit(); ၿဖင္႔ လက္ရွိေနရာမွ ထြက္လွ်င္ က်န္ရွိေသာ အလုပ္မ်ားဆက္မလုပ္ေတာ႔ ဘဲ လက္ရွိ run ေနသည္႔ကုိ ရပ္တန္႔သြားပါလိမ္႔မည္ ..

eg .

<?php
$con=mysqli_connect(“myexample.com”,”william”,”db123″,”my_db”);
// Check connection
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}

$result = mysqli_query($con,”SELECT * FROM Persons”);

echo <table border=’1′>
<
tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>”;

while($row = mysqli_fetch_array($result))
{

 var_dump($row);
echo “<tr>”;
echo “<td>” . $row[‘FirstName’] . “</td>”;
echo “<td>” . $row[‘LastName’] . “</td>”;
echo “</tr>”;
}
echo “</table>”;

mysqli_close($con);
?>

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Javascript  ေရးသည္႔ အခါလည္း  PHP မွသယ္လာေသာ Data မ်ားကို စစ္ၿကည္႔ခ်င္သည္႔ အခါ …..
php မွ server ဆီသို႕သြားၿပီး သယ္ယူလာလည္႔ data မ်ားကို  json format အေနနဲ႔ေၿပာင္းၿပီး  alert(data1.join(“\n”)); အေနနဲ႕ ထုတ္ယူၿကည္႔ရႈႏုိင္ပါသည္

var data1 = <?php echo json_encode(test()); ?>;
 alert(data1.join(‘\n’));

<?php function test()
{
return $arrData;
}
?>

Advertisements

Wamp Server ႏွင္႔ MySql ကို Run မရၿခင္း

Windows 7 32 bits  and WampServer 2.2
PHP 5.3.13
Apache 2.2.22
MySql 5.5.2

Windows မွာ Visual Studio 2010 ႏွင္႔ SqlServer 2008 တင္ၿပီးသည္႔ အခါ Wamp Server ကို
Browser မွ Run သည္႔ အခါ localhost ၿဖင္႔ေခၚလုိ႔မရၿဖစ္ခဲ႕လွ်င္ …..

Wamp Server အတြက္

Web Server Run သည္ႏွင္႔ ဆက္စပ္မႈရွိေသာ  Microsoft Services မ်ားအခ်ဴိ႕ကို  Stop လုပ္ဖုိ႔ လိုအပ္ ပါသည္ …
eg.
MSSQLSERVER services
Firewall Service
IIS သြင္းထားခဲ႔လွ်င္  IIS အတြက္ Run ထားေသာ web services မ်ားကိုလည္း ပိတ္ဖုိ႔ လိုအပ္ ပါသည္ …
Skype တို႕ကဲ႔သို႔ေသာ port 80 ကို ယူသံဳးေသာ application မ်ားရွိလွ်င္လည္း ပိတ္ဖုိ႔ လုိအပ္ ပါသည္ ….

အကယ္၍ …. Wamp Server ရဲ႕ Port 80 ကို တစ္ၿခား Port ေၿပာင္းသံုးလုိလ်ွင္ေတာ႔ …. Apache ရဲ႕ httpd.conf file ထဲမွ Port 80 ကို ေၿပာင္းလုိေသာ Port No တစ္ခုသုိ႔ေၿပာင္းၿပီး  localhot:8080/ အေနၿဖင္႔  Browser မွေခၚၿပီး Run လွ်င္ရပါႏုိင္ပါသည္ ( httpd.conf file path => C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf)

PhpMyadmin ကို Browser မွ ေခၚ၍မရခဲ႕လွ်င္ ……

Change the file content of c:\wamp\alias\phpmyadmin.conf to the following.

<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order Deny,Allow
        Allow from all
</Directory>

Here my WAMP installation is in the c:\wamp folder. Change it according to your installation.

Previously, it was like this:

<Directory "c:/wamp/apps/phpmyadmin3.4.5/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
</Directory>