WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-24-2005, 01:28 AM
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: United Kingdom
Posts: 1,762
TrafficProducer RepRank 0
Default MySQL Bug!!!

MySQL Bug!!!

I keep getting:-
Can't call method "prepare" on an undefined value at sql_test.cgi

I've tried all the user id's I can think of:

phpMyAdmin displays:-

localhost

hostlogonuser_test No tables found in database.

test has tables which function as expected using Query’s via phpMyAdmin

code:-

#!/usr/bin/perl

# sql_test.cgi

use DBI;

use CGI::Carp qw(fatalsToBrowser);

use DBI;

&ReadParse(*input);

$database_name=$input{'database_name'};
$host=$input{'host'};
$user_ID=$input{'user_ID'};
$password=$input{'password'};

$trace_level=$input{'trace_level'};

$sqlstatement=$input{'sqlstatement'};


print("Content-Type: text/html\n\n");

print << "head";

<html>
<HEAD>
<TITLE>SQL Test</TITLE>

<META name="description" content="SQL Test">

<META name="keywords" content="SQL Test">

<META NAME="ROBOTS" CONTENT = "All">

</HEAD>

<body>

head

if($database_name eq "" or $host eq "" or $user_ID eq "" or $password eq "" or $sqlstatement eq "")
{
print "<h3>ERROR missing data: SQL Test. Compare Bargains.</h3>

\n";

print "Database name==>$database_name
";
print "Host $host
";
print "user_ID==>$user_ID
";
print "password==>$password

\n";
print "SQL statement:
$sqlstatement

\n";
}
else
{
print "<h3>SQL Test. Compare Bargains.</h3>

\n";

print "Database name==>$database_name
";
print "Host $host
";
print "user_ID==>$user_ID
";
print "password==>$password

\n";
print "SQL statement:
$sqlstatement

\n";

## $drh = DBI->install_driver("mysql");

print "Drivers:-

\n";;

my @drivers = DBI->available_drivers();

die "No drivers found!\n" unless @drivers; # should never happen

### Iterate through the drivers and list the data sources for each one
foreach my $driver ( @drivers ) {
print "Driver: $driver\n";
my @dataSources = DBI->data_sources( $driver );
foreach my $dataSource ( @dataSources ) {
print "\tData Source is $dataSource

\n";
}
print "

\n";
}

#### Trace level is a number between 0 and 9 but usually 2 is sufficient.

# 0 - Trace disabled.
# 1 - Trace DBI method calls returning with results or errors.
# 2 - Trace method entry with parameters and returning with results.
# 3 - As above, adding some high-level information from the driver
# and some internal information from the DBI.
# 4 - As above, adding more detailed information from the driver.
# Also includes DBI mutex information when using threaded Perl.
# 5 and above - As above but with more and more obscure information.

if(($trace_level<0) or ($trace_level>9))
{
$trace_level=0
}

print "Trace level, error checking==>$trace_level

\n";

DBI->trace($trace_level);
#### Send to file DBI->trace($trace_level, $trace_filename);

# LOCAL MS Access test: open connection to Access database
# WAS $dbh = DBI->connect('dbi:ODBC:test');

# Recomended Perl $dbh = DBI->connect("DBI:mysql:jhdavmfk_test:localhost","jhda vmfk_","<PASSWORD HERE>");

print "SQL Statement==>$sqlstatement<==

\n";

# Database Name:Host,UserID,password

$dbh = DBI->connect('DBI:mysql:$database_name:$host,$user_ID, $ password',{RaiseError=>1, AutoCommit=>1});

# Prepare and execute SQL statement
$sth = $dbh->prepare($sqlstatement);

$sth->execute || die "Could not execute SQL statement ... maybe invalid?";

# Output database results

while (@row=$sth->fetchrow_array)
{
print "@row<hr>\n";
}

$dbh->disconnect();
}

print "</body></html>\n";

###

.....

ReadParse code works....


Thank you.
__________________
Videos to Watch and Video Publishing
Affiliate Program! Our Affiliate Program Pays 50.00% Business Support
Reply With Quote
  #2 (permalink)  
Old 08-04-2005, 01:12 PM
Evic's Avatar
WebProWorld Pro
 

Join Date: Jul 2005
Location: Eielson AFB, AK
Posts: 174
Evic RepRank 0
Default

Well, I don't know perl, but what really stood out to me was this:

Quote:
phpMyAdmin displays:-

localhost

hostlogonuser_test No tables found in database.

test has tables which function as expected using Query’s via phpMyAdmin
Some webhosts will have you name your database (let's say you named it test), but the actual database is named username_test. You must refer to that database as such within your code.

So, make sure your code is referring to username_test (the one phpMyAdmin says has no tables) rather than just test (the one you say does have tables).
__________________
Michael Wales

My Blog: GibThis: Video Game Blog
Reply With Quote
  #3 (permalink)  
Old 08-05-2005, 06:13 PM
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: United Kingdom
Posts: 1,762
TrafficProducer RepRank 0
Default It works now, the problem now is!

It works now, the problem now is too slow searching 500Mb Plus, (over 1,000,000 links)

This may now function all the time as it is be debugged now!

Test page only
__________________
Videos to Watch and Video Publishing
Affiliate Program! Our Affiliate Program Pays 50.00% Business Support
Reply With Quote
  #4 (permalink)  
Old 11-26-2005, 01:31 PM
WebProWorld 1,000+ Club
 

Join Date: Jul 2003
Location: United Kingdom
Posts: 1,762
TrafficProducer RepRank 0
Default Thanks for the help

Thanks for the help :)

I've sorted it out now, well there always room for impovement.

(I use a different PERL script)

Thanks for the help :)
__________________
Videos to Watch and Video Publishing
Affiliate Program! Our Affiliate Program Pays 50.00% Business Support
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0