Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL webpage connection problem

Status
Not open for further replies.

pepy

Technical User
Jan 14, 2004
19
US
i have made a mysql database at freesql.org
i can connect to it using different myadmin progams.

but i cant for the life of me connect to it using a web page??
For "weeks" i have tried many different ways using php.

freesql.org is not my server, this may have something to do with it??
I have tried 100s of different ways to connect to it....
below is one of the ways i have tried....

Maybe one of you can see what i am doing wrong
Please help

Thank you
Pepy


<html>
<head>
<TITLE></TITLE>
<META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html&quot;>

</head>

<BODY>

<?
$username=&quot;xxxxxxxxxxxxxx&quot;;
$password=&quot;xxxxxxxxxxxxxx&quot;;
$database=&quot;dbsell&quot;;

$db = mysql_connect(&quot;freesql.org&quot;, $username, $password);
@mysql_select_db(dbsell) or die( &quot;Unable to select database&quot;);

$query=&quot;SELECT * FROM t1&quot;;
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();


echo &quot;<b><center>Database Output</center></b><br><br>&quot;;

$i=0;
while ($i < $num) {

$domain=mysql_result($result,$i,&quot;name&quot;);
$code=mysql_result($result,$i,&quot;code&quot;);


echo &quot;<b>$domain $code</b>&quot;;

++$i;
}

?>

</body>
</html>

 

right now freesql.org is down...
MySQL Connection Failed: Too many connections


this is a dumb question but i better ask it,
freesql.org is just someone who offers the abillity
for ppl like me to make a mysql batabase on his website.
he has the mysql and php4.0 loaded on it.

question...
i dont need to have mysql and php4.0 loaded on my personal computer
to connect to it do i?

i am finding it hard to understand why philote can connect to it and i cant???? i am under the imperssion as long as the server where the database is loaded has it the computer accessing it doesnt need it.

and there was two apples on the tree....

 

well another day another try....

tshot, not sure what your saying, i can connect to the database with different admins... DBDesigner-4,
mysqlcc, myadmin, and of corse freesql's admin.

I just cant connect to it via webpage........
and now i have philote saying she/he can??????
Thats why i asked the question in my last post...
i can not come up with any other reason why she/he can i cant, only that God doesnt like me and life is unfair.

Going to church doesn't make you a Christian any more than going to a garage makes you a mechanic.

I think my next girl friend should be a database consultant?
 
pepy-
This is quick and dirty, but it works ok.
<?

$username=&quot;pepy&quot;;
$password=&quot;damit&quot;;
$database=&quot;dbsell&quot;;

// Connect to MySQL.
$db = mysql_connect(&quot;freesql.org&quot;, $username,$password);
if (!$db)
{
echo &quot;Error: Could not connect to database.&quot;;
exit;
}

echo &quot;Connection made.&quot;;

// $mysql=mysql_select_db(&quot;dbsell&quot;);

// See what tables are in database.
$query=&quot;show tables from dbsell&quot;;
$result = mysql_query( $query,$db ) or die(&quot;Select Error: &quot; . mysql_error() . &quot; in Query: $query&quot;);
while($row = mysql_fetch_array($result))
{
echo $row[0];
}

?>
 
pepy-
Obviously, take the two slashes out in front of $mysql . . . etc. in my post (don't know how they got there!!)
 
Thank you rgbatson
but when i loaded -

---------------------------------------------------------
<html>
<head>
<TITLE></TITLE>
<META http-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html&quot;>
</head>

<BODY>
<?

$username=&quot;pepy&quot;;
$password=&quot;damit&quot;;
$database=&quot;dbsell&quot;;

// Connect to MySQL.
$db = mysql_connect(&quot;freesql.org&quot;, $username,$password);
if (!$db)
{
echo &quot;Error: Could not connect to database.&quot;;
exit;
}

echo &quot;Connection made.&quot;;

$mysql=mysql_select_db(&quot;dbsell&quot;);

// See what tables are in database.
$query=&quot;show tables from dbsell&quot;;
$result = mysql_query( $query,$db ) or die(&quot;Select Error: &quot; . mysql_error() . &quot; in Query: $query&quot;);
while($row = mysql_fetch_array($result))
{
echo $row[0];
}

?>
</body>
</html>
--------------------------------------------------------


it retunred these errors -

Warning: Can't connect to MySQL server on 'freesql.org' (13) in /mnt/web_i/d25/s15/b01ce1a1/ on line 15

Warning: MySQL Connection Failed: Can't connect to MySQL server on 'freesql.org' (13) in /mnt/web_i/d25/s15/b01ce1a1/ on line 15
Error: Could not connect to database.

---------------------------------------------------------

line 15 is -

$db = mysql_connect(&quot;freesql.org&quot;, $username,$password);


--------------------------------------------------------


so you guys actualy made a php web page on your site and connected to this?
and i cant?

or are you just telling me it should work?

those are the right user name and password.

i just want to know if anyone can connect to it first.
thank you
pepy
 
Running this part of your code:

Code:
<?
$username=&quot;pepy&quot;;
$password=&quot;damit&quot;;
$database=&quot;dbsell&quot;;

$db = mysql_connect(&quot;freesql.org&quot;, $username,$password);
if (!$db)
{
   echo &quot;Error: Could not connect to database.&quot;;
   exit;
}

echo &quot;Connection made.&quot;;
?>

I get &quot;Connection made&quot;.


Is the machine from which you are connecting via the various GUI MySQL apps the same as the one on which you're running your PHP code?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Yes, this works because I have Apache server and PHP running on my windows 98 PC, and I give this file a .php extension. (I also have MySQL running, but that is not needed in this instance.) I call this file through my browser, pointing it to Apache at Local PHP interprets the code and sends via http to connect to the remote MySQL server at freesql.org, using the sign-in parameters you supply.
Ordinarily, I would ftp my program files to the Web server, where they could be called/accessed from any browser anywhere. The programs would then access the localhost (that is, the Web server), and return the result as pure html to the requesting browser.
 
Yes, pepy, we really made the connection. Here are your tables:
Connection made.BookBookOrderCancellationCustomerEmployeeInvoiceInvoice_has_BookNewsOrder_consists_ofPublisheraat1
 

ok i am a little confused here in what i need then...

freesql.org has mysql, php and i asume they would have Apache too?

are you saying that i have to have php & Apache loaded on my computer or up loaded to my ftp site?.....
even thuo freesql.org is where the database is?
 

and if so, would this problem be corrected if my ftp site was also the host for my database?

i have always thought that this was the problem?
not being able to say localhost that is, making his php useless to me?

and thank you for your reply rgbatson
 

sleipnir214
no, freesql.org is running the php and mysql.
my ftp site is netfirms.com
 
pepy -
There is so much to cover, and one needs to know more about your technical background to know where to start. If you wish, email me at rgbatson@bellsouth.net with a brief resume of what you have used and worked on before, so I can see if I can be of help. I am motivated to try because far and away the hardest problem I ever had was establishing that very first MySQL connection, even after years of earlier database programming on a lan! Now it all seems so easy . . . .
 
intrestingly peppy i am with u. earlier i was using php parser to execute the code directly but when i treid it using Konqueror (Linux) it gave me same error. I tried the localhost also.

OK now we can explore it jointly. It may be a browser feature also + php as PHP is a server side script. But some explanation needed for Win98 Explorer

Besides for prractisong wy don' u try


[ponder]
----------------
ur feedback is a very welcome desire
 
pepy, according to those error messages you've been giving it appears as though you have most everything set up right and the code's trying to connect but can't. Are you running this web page on the same computer that you were able to connect from using other methods? Or are you uploading it somewhere else?

 
rgbatson ,

resume? lol

i have been on the computer for 4-1/2 years.
self taught.

i can use databases and spead sheets on my own computer lotus 123, very well, joining tables making grafts legger books, the dreded @if clause! lol

i can make web sties with all the html basics, ccs, ssi, ect. and get good listing placement on google

i can configure premade perl scripts for flat batabase with muti scripts add make the html templates for them.
with in a week of getting in to my first cgi-bin at netfirms becuz AOL sucks! and doesnt have it. I starter this cgi flat file for selling domain names


but stoped and never finished it becuz i realized then it can only handle 3MB of txt and from what i can see i will require 30 to 50...... maybe more with sql?


i understand there is a few programs and files working together to execute and show the final html for the user.

i understand the concept of commin joined talbles and normalization of tables and the basic sql inquires, import export, of the sql data i can do.

i understand the theroy of groups and permissions for user sign ins. default, user, admin, ect.


I even know the Apache, php and mysql must combined to make it all for, i was under the impression i only needed it on my comp if i was going to set up as a dedacated server thuo?

if i can connect i can do the rest, i know it will take me about a year to pull it together. There even free program scripts that i can modify to what i want........ if only i can connect.

I once tired this sql about 3 years ago for about two months and then gave up cuz i realized aol doesnt support it and i learned how to remove there banner form my business site so was i happy.

The whole reason why i started the comp was to make web sites, get good listings, accept credit cards and have ppl enter the data, self encifent interactive web site.

all for the chance that i can come across a good service product or info that i might sell to the world becuz the are no real adverising cost on the net.

i have also found out i like working on computers as well......... thus the 4 weeks just trying to connect to mysql lol.

is that what you meant by resume? lol
 
tshot
yes i am on win98, IE 6, med security settings, no fire wall.
 
philote,

yes all on this computer.

win98, IE 6, med security settings, no fire wall.
ibm, 400hz, 128 ram 56k moden, AOL ISP, netfirms.com host
freesql.org remote database.

i can connect with all my admin programs, just not by php web page loaded up to up ftp at netfirms.
 
tshot
i saw that link before in this forum somewhere
i was at that site 3 days ago-


i cant read german...lol

thats where i found out that i would need all three of them, but it is a 28MB and on my 56K its a 2 hour download
was going to do it while sleeping one night,
or keep the url handy for later
i like the idea of them already being configure together.

but i am still under the imperession that only the remote host requires the mysql, Apache and php.
and that you dont have to be a deitcated server yourself?
 
pepy, the problem has to be with netfirms, since that's where your site is hosted. The web site host must have php support on their servers for your page to work. It seems like this is the case, but for some reason you're having problems actually connecting to the database from netfirms. This leads me to believe that maybe they have a firewall or something blocking your access to freemql.org's databases.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top