You are here: Re: [PHP] My FIRST php atempt « PHP « IT news, forums, messages
Re: [PHP] My FIRST php atempt

Posted by M. Sokolewicz on 02/18/05 10:37

Bret Hughes wrote:
> On Fri, 2005-02-18 at 01:47, David Freedman wrote:
>
>>I am trying my FIRST php file with an attempt to connect
>>to my mySql server.
>>
>><?php
>>// Connecting, selecting database
>>$link = mysql_connect('localhost', 'host', 'my_passqword')
>> or die('Could not connect: ' . mysql_error());
>>echo 'Connected successfully';
>>mysql_select_db('eatc7402') or die('Could not select database');
>>
>>// Performing SQL query
>>$query = 'SELECT * FROM my_table';
>>$result = mysql_query($query) or die('Query failed: ' . mysql_error());
>>==============================
>>more code to print results.
>>..
>>..
>>============================
>>// Free resultset
>>mysql_free_result($result);
>>
>>// Closing connection
>>mysql_close($link);
>>?>
>>
>>The problem is it won't connect to the database. The server IS running. The
>>host, username,
>>and password are the exact same thing I use to connect the mySqlAdmin tool
>>to the database.
>>Doesn't seem like this should be that difficult. How can I discover why it
>>doesn't
>>seem to connect.
>>
>
>
> what is in the mysql log? chances are it is a db permission issue since
> you are not running as the same user as the server is.
>
> There was a thread like this earlier this week maybe even today?
>
> look in the archives of this list.
>
> Bret
actually, I'd suggest he first take another look at his mysql_connect()
call... I can't recall mysql_connect taking the hostname argument
*twice*! as in mysql_connect('localhost', 'host', 'password'); I'd bet
"host" should be replaced with "password"

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация