Click to See Complete Forum and Search --> : ODBC SQL.. dunno if theres an error or not but..
wpearsall
Dec 27th, 2002, 10:23 PM
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:
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:
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
phpman
Dec 30th, 2002, 09:22 AM
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.
techgnome
Dec 30th, 2002, 09:57 AM
phpman -- he's not using mysql, he's using Access...... which is why he's using odbc.... why it's not working though....... :confused:
phpman
Dec 30th, 2002, 10:02 AM
then I misunderstood this :)
"and in it it has functionality for ODBC mSQL, MySQL etc, (and a ton of others). "
wpearsall
Dec 30th, 2002, 01:20 PM
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
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)
$dbhost = "127.0.0.1";
$dbuname = "root";
$dbpass = "*****";
$dbname = "search_engine";
$dbtype = "MySQL";
is what i use for MySQL
$dbuname = "username";
$dbpass = "password";
$dbname = "ODBC_NAME";
$dbtype = "ODBC";
for ODBC.
so im a lil lost at it,
phpman
Dec 30th, 2002, 01:32 PM
it can't be doing the sql if it isn't inserting anything.
you are doing inserts and not selects right?
wpearsall
Dec 30th, 2002, 02:55 PM
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...
phpman
Dec 30th, 2002, 02:58 PM
how are you creating a table in excel ?
what is the exact code and what db are you working with?
wpearsall
Dec 30th, 2002, 03:21 PM
ok, i havent tried it with excel or that, but with Access i have,
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);
}
phpman
Dec 30th, 2002, 04:51 PM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.