Android Question <b>Fatal error</b>: Uncaught Error: Call to undefined function pg_connect()

Pravee7094

Active Member
Hi all,

I recently using postgresql for database connection with php. But while running I got Error like <b>Fatal error</b>: Uncaught Error: Call to undefined function pg_connect() in C:\xampp\htdocs\loginphp\connection.php:2

Here is the B4a code:

B4X:
    #Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private xui As XUI
    Dim strURL As String = "http://192.XXX.X.XX:80/loginphp/"
    
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    
    Private pnlImage As Panel
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("splashscreen")
'    Sleep(2000)
'    StartActivity(login)
'    Activity.Finish
    TestConnection
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub TestConnection
    Dim Connect As HttpJob
    Connect.Initialize("Connect", Me)
    Connect.Download(strURL & "connection.php")
    ProgressDialogShow("Connecting...")
End Sub

Sub JobDone (Job As HttpJob)
    Dim phone As Phone
    ProgressDialogHide
    If Job.Success = True Then
        Dim connMsg As String
        Dim act As String
        Log(Job.GetString)
        connMsg = Job.GetString
        Dim parser As JSONParser
        parser.Initialize(connMsg)
        act = parser.NextValue
        If act = "Success"  Then
            ToastMessageShow("Login Successful",True)
            phone.HideKeyboard(Activity)
        End If
        If act = "Failure" Then
            ToastMessageShow("Login failure",True)
            phone.HideKeyboard(Activity)
        End If
    Else
        Log("Error: " & Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
  Job.Release
End Sub

Php code:
PHP:
<?php 
$dbconn = pg_connect("host=localhost port=5432 dbname=dbname user=postgres password=password"); 

 if (!$dbconn){ 
  print json_encode ("Failure"); 
}
 else {
  print json_encode ("Success"); 
 }
?>

Anybody Help?

Thanks
Praveen
 
Top