Mysql to Postgresql Connection

Codes here !

Moderators: macek, egami, gesf

davedran
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Jun 25, 2014 10:00 pm

Mysql to Postgresql Connection

Postby davedran » Wed Jun 25, 2014 10:02 pm

Hi!

How do I rewrite this from MySql to Postgresql

<?php

$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("kpi", $con);


?>

Thank you.

David

aymanoz1
New php-forum User
New php-forum User
Posts: 4
Joined: Wed Jun 25, 2014 8:25 am

Re: Mysql to Postgresql Connection

Postby aymanoz1 » Wed Jun 25, 2014 10:55 pm

Try This

Code: Select all

<?
  $con= pg_Connect("dbname=kpi user=root password=anypassword");
  $result = pg_exec($con, "select * from table1");
  $numrows = pg_numrows($result);
 ?>

<!-- CODE CODE CODE -->


<?php
pg_close($con);
  ?>


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest