Results 1 to 10 of 10

Thread: ODBC SQL.. dunno if theres an error or not but..

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    ODBC SQL.. dunno if theres an error or not but..

    OK, i have an SQL_Layer.php file etc, and in it it has functionality for ODBC mSQL, MySQL etc, (and a ton of others).

    any how, with it, it connects to the ODBC Server using:

    PHP Code:
    odbc_connect($db,$user,$password); 
    now for $db, i have put my ODBC Datasource name "SearchAccess"

    and i set it all up right, (i think).

    in my cp/admin tools/ data sources (odbc)

    made a new data source, and made a new MS Access database.

    etc.

    and ne how, i added a username of "user" and password of "pass" and checked it with some SQL Queries,

    now, on the php script, i set error_reporting to E_ALL

    and so on,

    any how, it does the SQL for it by:

    PHP Code:
    odbc_exec($id,$query);
    // $id being the connection ID 
    any how, no errors are returned by the sql query, no warnings, nothing, but, no tables are created, or no inserts are done on the tables,

    so im wondering, how do i go about doing a ODBC Data Source with php? (The $db should be the name? or?)

    ta
    Wayne

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    did you try echoing the odbc_error() or odbc_errormsg() ?

    also why are you using odbc for just plain mysql?

    also try echoing out the sql when it executes. that way you at least know it is getting that far.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    phpman -- he's not using mysql, he's using Access...... which is why he's using odbc.... why it's not working though.......
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    then I misunderstood this


    "and in it it has functionality for ODBC mSQL, MySQL etc, (and a ton of others). "

  5. #5

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Originally posted by phpman
    did you try echoing the odbc_error() or odbc_errormsg() ?

    also why are you using odbc for just plain mysql?

    also try echoing out the sql when it executes. that way you at least know it is getting that far.
    OK, this is the sql_layer.php file i have attached,

    depending on what $dbtype is selected, it will translate

    PHP Code:
    sql_query("SELECT * FROM TABLE WHERE THIS=THIS"$dbi);

    // To
    mysql_query("SELECT * FROM...

    odbc..

    msql... 
    etc, so it can use an Excel spreadsheet for the datastorage, or access database.,

    it is doing the sql, but no errors are returned, and nothing is made on the database (however, for plain mysql is is, (even thru the sql_layer.php)

    PHP Code:

    $dbhost 
    "127.0.0.1";
    $dbuname "root";
    $dbpass "*****";
    $dbname "search_engine";
    $dbtype "MySQL"
    is what i use for MySQL

    PHP Code:

    $dbuname 
    "username";
    $dbpass "password";
    $dbname "ODBC_NAME";
    $dbtype "ODBC"
    for ODBC.

    so im a lil lost at it,
    Attached Files Attached Files
    Wayne

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    it can't be doing the sql if it isn't inserting anything.

    you are doing inserts and not selects right?

  7. #7

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    yeh,

    CREATE TABLE TABLENAME(###)
    INSERT INTO TABLENAME (#,#,#,#) VALUES ('#','#','#','#')

    It works with MySQL but ODBC?

    I even tried with the plain connection things in PHP and it doesnt work either...
    Wayne

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    how are you creating a table in excel ?

    what is the exact code and what db are you working with?

  9. #9

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    ok, i havent tried it with excel or that, but with Access i have,

    PHP Code:
    function do_sql(){
        global 
    $dbi$prefix$user_prefix$sql_debug;

    #
    # Table structure for table `".$user_prefix."banner_ads`
    #

    sql_query("CREATE TABLE `".$user_prefix."banner_ads` (
      `ad_id` int(11) NOT NULL auto_increment,
      `date` varchar(50) NOT NULL default '',
      `account_name` varchar(255) NOT NULL default '',
      `account_type` int(1) NOT NULL default '1',
      `click_url` text NOT NULL,
      `image_url` text NOT NULL,
      `alt_text` text NOT NULL,
      `raw_code` text NOT NULL,
      `active` int(1) NOT NULL default '0',
      `unlimited` int(1) NOT NULL default '0',
      `credits_left` int(11) NOT NULL default '0',
      `imps_total` int(11) NOT NULL default '0',
      `imps_made` int(11) NOT NULL default '0',
      `clicks_recieved` int(11) NOT NULL default '0',
      PRIMARY KEY (`ad_id`)
    )"
    $dbi);
    # --------------------------------------------------------

    #
    # And more of create tables
    #

    #
    # Dumping data for table `".$user_prefix."banner_ads`
    #

    sql_query("INSERT INTO `".$user_prefix."banner_ads` (`ad_id`, `date`, `account_name`, `account_type`, `click_url`, `image_url`, `alt_text`, `raw_code`, `active`, `unlimited`, `credits_left`, `imps_total`, `imps_made`, `clicks_recieved`) VALUES
    (1, '2002-12-14 15:35:06', 'wayne', 1, 'http://web-software.ods.org/', 'http://ew-search.realm-ed.co.uk:88/template/images/logo.gif', 'Web-Software.ods.org', '', 1, 1, 1, 0, 247, 5)"
    $dbi);


    Wayne

  10. #10
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    ok that all looks fine to me. and you are sure it is connecting ok? can you echo it out saying something like "yes got connection" right after it connects. is there anyway to echo out the query so you can see it do its job?

    something has to be happening.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width