Uncomment following lines in your php.ini and you are good to go.
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
I hope this helps. Thanks!!!!
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Tuesday, May 19, 2015
Sunday, April 13, 2014
Connect Remote MSSQL Server with PHP
Connect MSSQL Server with PHP
<?php
$server = 'xxx.xxx.xxx:port';
// Connect to MSSQL
$link = mssql_connect($server, 'user', 'password');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
if($link)
{
echo mssql_get_last_message();
mssql_close();
}
?>
You can use localhost instead of ip or url if you are connecting on the same machine. :) Thanks :)
Thursday, February 2, 2012
IIF in php
(expr1) ? (expr2) : (expr3)
If expr1 is True, THEN do expr2, ELSE do expr3.
Sunday, January 29, 2012
How to change default Apache page?
If you wanna change the home page for your apache server, you can change it easily in httpd.conf which is located in D:\XAMPP\apache\conf\
Just add your desired file to be an index page for your site. :) Good Luck and all the best.
<IfModule dir_module>
DirectoryIndex xxxx.php index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
Tuesday, January 17, 2012
Uploading and Save CSV file in MySQL database with PHP
Uploading and Save CSV file in MySQL database with PHP
<?php
include("opendb.php");
//echo isset($_POST['submit']);
if(isset($_POST['submit']))
{
$filename=$_FILES['files']['name'];
$filename=date('U').$filename;
$add1 = "import/$filename";
move_uploaded_file($_FILES[files][tmp_name], $add1);
chmod($add1,0777);
basename($_FILES['files']['name'] );
$filename1="import/$filename";
$fcontents = file ($filename1);
echo sizeof($fcontents);
for($i=0; $i<sizeof($fcontents); $i++) {
$line = addslashes(trim($fcontents[$i]));
$arr = explode("\t", $line);
echo "<pre>";
print_r($arr);
//exit();
//echo $arr;
$Repl_arr=array("[","]");
//echo $Repl_arr;
foreach($arr as $key=>$val)
{
$arr[$key]=str_replace($Repl_arr,"",$arr[$key]);
$arr_new=$arr[$key];
$arr_new1 = explode(",", $arr_new);
}
//echo "<PRE>";
//var_dump($arr_new1);
/*
$date=explode("/", $arr_new1[0]);
$dd=$date[0];
$mm=$date[1];
$yy=$date[2];
if(strlen($dd)==1){
$dd="0".$dd;
}
if(strlen($mm)==1){
$mm="0".$mm;
}
$date1=$yy."-".$mm."-".$dd;
*/
$name=$arr_new1[0];
$addr = $arr_new1[1];
//$email=$arr_new1[2];
//$amount=$arr_new1[3];
$sql = "insert into mytestupload set
tfield='$name',tfield1='$addr'";
//echo $sql;
//exit();
$qr=mysql_query($sql);
echo "-----------1 Row Inserted----------";
$sql ."<br><br>\n";
if($qr!=0)
$msg= "Data has been imported";
if(mysql_error()) {
echo mysql_error() ."<br>\n";
}
}
unlink($filename1);
unset($_POST);
$_POST['submit']='';
$_POST='';
//echo "<script>window.location=('addcsv.php');</script>";
} ?>
<html>
<head>
<title>Import CSV</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../css/decorate.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><table width="100%" border="0">
<tr>
<td height="25" align="center" class="label">Import CSV Tax File </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td valign="top"><form action="addbatchtext.php" method="post" enctype="multipart/form-data">
<table width="100%" border="1">
<tr>
<td width="30%" class="line2">File Name:</td>
<td width="70%" align="left" class="line2"><input name="files" type="file" class="inp"></td>
</tr>
<tr>
<td class="line2"> </td>
<td align="left" valign="middle" class="line2"> </td>
</tr>
<tr><td class="line2"> </td>
<td align="left" valign="middle" class="line2">
<input name="submit" type="submit" class="buttons" value="Submit" ></td>
</tr>
</table>
</form></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Wednesday, December 28, 2011
PHP Fatal error : Cannot break/continue 1 level
Because you are using break without "switch...case" or looping. You can solve this by changing "break" to "return" to exit from the function.
Enjoy!!! .. all the best... :)
Enjoy!!! .. all the best... :)
Monday, December 26, 2011
Where does MySQL database stored its data in my harddisk?
Where does MySQL database stored its data in my harddisk?
It depends on where you want it to be stored. Normally you can find the location of your mysql data files in this following config file.
C:\Program Files\MySQL\MySQL Server 5.1\my.ini
If you are using XAMPP, you can find it in here :
D:\xampp\mysql\bin\my.ini
But you may not need to look into that file since you can find your data files in this follow directory.
D:\xampp\mysql\data
Enjoy!! Thanks...
"Correct my if i am wrong by leaving comments down there" :D
It depends on where you want it to be stored. Normally you can find the location of your mysql data files in this following config file.
C:\Program Files\MySQL\MySQL Server 5.1\my.ini
If you are using XAMPP, you can find it in here :
D:\xampp\mysql\bin\my.ini
But you may not need to look into that file since you can find your data files in this follow directory.
D:\xampp\mysql\data
Enjoy!! Thanks...
"Correct my if i am wrong by leaving comments down there" :D
Wednesday, December 21, 2011
Using Flexigrid with PHP and MySQL
Flexigrid is a lightweight but rich data grid with resizable columns and a scrolling data to match the headers, plus an ability to
connect to an xml based data source using Ajax to load the content.
Features :
Features :
- Resizable columns
- Resizable height and width
- Sortable column headers
- Cool theme
- Can convert an ordinary table
- Ability to connect to an ajax data source (XML and JSON[new])
- Paging
- Show/hide columns
- Toolbar (new)
- Search (new)
- Accessible API
You can download it here to use it.
There are two formats you can get your data return to your page, in JSON or XML.
Follow this link, you can find a sample source code for returning in XML format, and for returning in JSON, follow here.
How it works:
First, you have to these three lines to your html page
<link rel="stylesheet" type="text/css" href="flexigrid/css/flexigrid.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="flexigrid/js/flexigrid.js"></script>
Please make sure that you add
<script type="text/javascript" src="jquery.js"></script> before <script type="text/javascript" src="flexigrid/js/flexigrid.js"></script> since it is using jquery to populate its grid.
then you can add the table definition which you want to show in your web page.
In this following example, the data will display in "flex1" table.
And the data will be processing in post2.php file and return to your html page in JSON format.
| <table id="flex1" style="display:none"></table> |
| <script type="text/javascript"> |
| $("#flex1").flexigrid({ |
| url: 'post2.php', |
| dataType: 'json', |
| colModel : [ |
| {display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'}, |
| {display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'}, |
| {display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'}, |
| {display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true}, |
| {display: 'Number Code', name : 'numcode', width : 80, sortable : true, align: 'right'} |
| ], |
| searchitems : [ |
| {display: 'ISO', name : 'iso'}, |
| {display: 'Name', name : 'name', isdefault: true} |
| ], |
| sortname: "iso", |
| sortorder: "asc", |
| usepager: true, |
| title: 'Countries', |
| useRp: true, |
| rp: 15, |
| showTableToggleBtn: true, |
| width: 700, |
| onSubmit: addFormData, |
| height: 200 |
| }); |
To get to the point here, please follow below steps to use Flexigrid in your webpage (in php or any languages) with MySQL or any databases.
Let's assume that you already had jquery.js in your root directory.
Step 1:
<link rel="stylesheet" type="text/css" href="flexigrid/css/flexigrid.css">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="flexigrid/js/flexigrid.js"></script>
Step 2:
| <table id="flex1" style="display:none"></table> |
| <script type="text/javascript"> |
| $("#flex1").flexigrid({ |
| url: 'post2.php', |
| dataType: 'json', |
| colModel : [ |
| {display: 'ISO', name : 'iso', width : 40, sortable : true, align: 'center'}, |
| {display: 'Name', name : 'name', width : 180, sortable : true, align: 'left'}, |
| {display: 'Printable Name', name : 'printable_name', width : 120, sortable : true, align: 'left'}, |
| {display: 'ISO3', name : 'iso3', width : 130, sortable : true, align: 'left', hide: true}, |
| {display: 'Number Code', name : 'numcode', width : 80, sortable : true, align: 'right'} |
| ], |
| searchitems : [ |
| {display: 'ISO', name : 'iso'}, |
| {display: 'Name', name : 'name', isdefault: true} |
| ], |
| sortname: "iso", |
| sortorder: "asc", |
| usepager: true, |
| title: 'Countries', |
| useRp: true, |
| rp: 15, |
| showTableToggleBtn: true, |
| width: 700, |
| onSubmit: addFormData, |
| height: 200 |
| }); **if you want to use xml, just replace dataType: 'json' with datatype:'xml'. Steps 3: Create the processing page in php or any language you like. |
You can use $("#flex1").flexReload(); to reload or refresh your flexigrid. But you have to put it in right location in order to use it effectively.
And you can find full sample source codes for flexigrid at https://code.google.com/p/flexigrid/source/browse/#svn%2Ftrunk%2Fdemo
Download flexigrid directly here. or go to flexigrid.info for more detail.
Be remind yourself not to forget ; semi-colon and cases since both javascript and php are case-sensitive scripting engines.
All the best!!! Enjoy!!!
Sunday, December 18, 2011
Binding data to dropdown list with php from mysql database
This is just a basic for some of you guys. But if you are new to it, it will take some times for you to figure it out. So, please follow the steps mentioned below, and you will get there in no time.
<select name="yourselection">
<option value="">--Select--</option>
<?php
$msql = mysql_query("SELECT * FROM manufacturer");
while($m_row = mysql_fetch_array($msql))
echo("<option value = '" . $m_row['m_code'] . "'>" . $m_row['m_name'] . "</option>");
?>
</select>
<select name="yourselection">
<option value="">--Select--</option>
<?php
$msql = mysql_query("SELECT * FROM manufacturer");
while($m_row = mysql_fetch_array($msql))
echo("<option value = '" . $m_row['m_code'] . "'>" . $m_row['m_name'] . "</option>");
?>
</select>
Subscribe to:
Posts (Atom)