Month: October 2010

Pop window in php

Hi

I have struggling for hours to find a code purely in php for a popup window. The code is quite simple but a bit tricky. it requires java script to be integrated in the php code.  Here it is

  1. value1=urlencode('some value');

  2. echo "<a href=\"javascript :window.open('page.php?param1=$value1','name1','height=320,width=240');\">pop-up</a>";

For example I need to add a code in my php script to open a pop up window, here it is;

echo "<a href=\"javascript:window.open('editspares.php?id=$spareid&refno=$reference_id','Edit Spare Parts','height=50,width=650');\">Edit</a>";

Advertisements

If you want to run two instance of apache, there is a trick. I tried this for easyphp & XAMPP on windows. I was already having a working XAMPP server on my windows PC. I installed easyphp on the same PC. Now when I tried to start apache it gave that firewall has block the port and therefore cannot start apache. you just need to change the port for apache . Edit the file \apache\conf\httpd.conf and edit l following line

Listen 12.34.56.78:80
to
Listen 127.0.0.1:1024

You can also try any other number. Also when you open the browser to run any script: Like

http://localhost:1024/info.php

or

http://127.0.0.1:1024/info.php

File info.php

<?php
phpinfo();
?>

How to add/allow special characters in mysql – php data interchange

To prepare data for insertion to a text field in MySQL via PHP use the
following function;

$raw_additional_notes=$_POST['additional_notes'];
$additional_notes = mysql_escape_string($raw_additional_notes);    ///to escape the special charecters		
and to get it back to normal after reading it from the database...
$raw_additional_notes= stripslashes($additional_notes);

Basically the special characters are allowed in mysql with backslaches (“\”) therefore to add any such charectar, string needs to rewritten according to mysql. Using mysql_escape_string() function  the slashes can be added in string.

stripslashes() can revert back the same string deleting slashes.