FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


ODBC and PHP connections





Scotty Too Hotty
I'm currently working on a project to setup a webform coded in PHP that has two functions.

Function 1: Generate an E-mail to a specified e-mail address in a specified format. (I have got this working no problem).

Function 2: My second function is i want to have the same information sent in the email in function 1 sent to a database as well either in the same code or in different code i currently have it set-up in the same script.

I have hosted my form and the Function 2 of the script on the Frihhost servers for testing. I am using a very basic form in order to isolate all issue before i commit massive amounts of variables to it.

Whenever i run the script it gives me an error message.

Previous Entries in database
Fatal error: Call to undefined function: odbc_connect() in /home/scottyto/domains/scotty.frih.net/public_html/work/DataAccess.php3 on line 21


I do have my ODBC connection set up locally on my computer. Would this need to be setup on the server i am hosting from? Because i am hosting from Frihost, i am unable to create on unless someone can explain to me how.

-OR-

Can this be host locally, and i am just unable to get it set up?
This is my coding.
Code:

<?php

function HTML_Head() {
    echo "
    <HTML><HEAD>
    <TITLE>Processing Form</TITLE>
    </HEAD>
    <BODY BGCOLOR=\"#D5D5AB\">";
}

function HTML_Foot() {
    echo "</body></html>";
}

function Database_Entries($msg) {
    echo $msg;
}

function Output_Entries() {

    $cnx= odbc_connect( 'Trial' , 'root', '' );
    if (!$cnx) {
        Error_handler( "Error in odbc_connect" , $cnx );
    }

    $cur= odbc_exec( $cnx, "select Index,FirstName,LastName,PhoneNumber from

People" );
    if (!$cur) {
        Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
    }
    echo "<table border=1><tr><th>Index</th><th>First Name</th>".
        "<th>Last Name</th><th>Phone Number</th></tr>\n";
    $nbrow=0;   

    while( odbc_fetch_row( $cur ) ) {
        $nbrow++;
        $Index= odbc_result( $cur, 1 );
        $FirstName= odbc_result( $cur, 2 );
        $LastName= odbc_result( $cur, 3 );
        $PhoneNumber= odbc_result( $cur, 4 );

        echo "<tr><td>$Index</td><td>$FirstName</td>".
            "<td>$LastName</td><td>$PhoneNumber</td></tr>\n";
    }

    echo "<tr><td colspan=2>$nbrow entries </td></tr></table>";

    odbc_close( $cnx);
}

function Error_Handler( $msg, $cnx ) {
    echo "$msg \n";
    odbc_close( $cnx);
    exit();
}

function Enter_New_Entry($FirstName,$LastName,$PhoneNumber) {

    $cnx = odbc_connect( 'Trial' , 'root', '' );
    if (!$cnx) {
        Error_handler( "Error in odbc_connect" , $cnx );
    }
    $SQL_Exec_String = "Insert Into People (FirstName, LastName, PhoneNumber)
            Values ('$FirstName', '$LastName', '$PhoneNumber')";

    $cur= odbc_exec( $cnx, $SQL_Exec_String );
    if (!$cur) {
        Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
    }

    odbc_close( $cnx);
}

$strOldEntries = "Previous Entries in database";
$strNewEntries = "Updated version of databse (after entries)";

HTML_Head();
Database_Entries($strOldEntries);
Output_Entries();
Enter_New_Entry($FirstName,$LastName,$PhoneNumber);
Database_Entries($strNewEntries);
Output_Entries();
HTML_Foot();

?>


Any Help is very much appretiated,
Scotty Too Hotty
please note,

this is the tutorial i am running through. I am not a PHP coder, i am just Free-Lance, and learning.

http://www.phpbuilder.com/columns/siddarth20000228.php3?page=1[/url]
Scotty Too Hotty
PLEASE anything will help me at this point
kv
Looks like you are running this on unix. Unlike windows, on unix, odbc support is not build in for php. You may have to rebuild with odbc support or may have to add some library in your php.ini. Check php docs.
thnn
I dont know if its avaliable on frihost. You will have to ask to ask or PM bondings.
Scotty Too Hotty
actually, i am trying to run it on windows. I am canabalising code from tutorials etc.

I should be able to get the server specs i will be hosting this on. I was hosting it here in hopes of testing the code.
Related topics
How To : Improve Your PHP Programming
How To : Secure Your PHP Website
PHP Tutorials
PHP VS ASP
php upload issue
PHP script installation for $4 or FRIH$ 30 (Worth $1000)
mySQL Query/PHP code - get the highest value...
simple php to mysql form doesn't work
PHPbb3?
Instalação do forum phpBB2 no Frihost
PhpInstall.net - Looking for PHP scripters
Database connections failes after new month
Difficulty in accessing Frihost & Frihost forums
Mysql and PHP separately to work on windows 7
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.