Dec 27th, 2002, 11:23 PM
#1
Thread Starter
Frenzied Member
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
Dec 30th, 2002, 10:22 AM
#2
Frenzied Member
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.
Dec 30th, 2002, 10:57 AM
#3
phpman -- he's not using mysql, he's using Access...... which is why he's using odbc.... why it's not working though.......
Dec 30th, 2002, 11:02 AM
#4
Frenzied Member
then I misunderstood this
"and in it it has functionality for ODBC mSQL, MySQL etc, (and a ton of others). "
Dec 30th, 2002, 02:20 PM
#5
Thread Starter
Frenzied Member
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
Dec 30th, 2002, 02:32 PM
#6
Frenzied Member
it can't be doing the sql if it isn't inserting anything.
you are doing inserts and not selects right?
Dec 30th, 2002, 03:55 PM
#7
Thread Starter
Frenzied Member
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...
Dec 30th, 2002, 03:58 PM
#8
Frenzied Member
how are you creating a table in excel ?
what is the exact code and what db are you working with?
Dec 30th, 2002, 04:21 PM
#9
Thread Starter
Frenzied Member
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 );
}
Dec 30th, 2002, 05:51 PM
#10
Frenzied Member
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
Forum Rules
Click Here to Expand Forum to Full Width