PDA

View Full Version : Mysql Connection Error :(



TRshady
12-16-2003, 06:40 PM
Following This Tutorial (http://www.evilwalrus.com/articles.php?aid=39&pid=1), I have got This Far (http://trshady.com/dbtest.php) and can't connect :(.

I replaced this:


<?
&nbsp; &nbsp; &nbsp; &nbsp; &#036;dbcx = mysql_connect("localhost","username","passw0rd");

To This:

<?
&nbsp; &nbsp; &nbsp; &nbsp; &#036;dbcx = mysql_connect("localhost","db_user","passwordiset");

But it wont connect, the database is called db_tutorial if thats supposed to replace anything, please help someone, trying this (what should be simple tut), but am always getting more problems :cry:

TRshady
12-16-2003, 08:09 PM
:&#39;( Please Someone .......
I&#39;m following a beginners guide, lol, so someone must be able to point out what I&#39;m doing wrong ...

I.am
12-16-2003, 09:51 PM
TRShady, it seems the password is set wrong. Check the case of the password.


Edit: Where is the mysql server hosted?

TRshady
12-16-2003, 10:00 PM
The mysql server is hosted on the same server. Got 10gbs as a part of a hosting package. Thanks though, I&#39;ll try adding another user and password.

TRshady
12-16-2003, 10:15 PM
I feel stupid ... please ignore me from now on, lol.
The connection strings is directly underneath the db in cpanel ... I always wondered what they&#39;re there for, lol. Thanks for trying to help :D

I.am
12-16-2003, 10:18 PM
Originally posted by TRshady@16 December 2003 - 17:15
I feel stupid ... please ignore me from now on, lol.
The connection strings is directly underneath the db in cpanel ... I always wondered what they&#39;re there for, lol. Thanks for trying to help :D
You&#39;re most welcome :)

So what was the problem?

TRshady
12-16-2003, 10:25 PM
First off, the username was wrong, instead of &#39;user&#39;, it has to be put as trshady_user ... and same applies to database needing a prefix of &#39;trshady_&#39;. :)

I.am
12-16-2003, 10:32 PM
TRShady, it seems the password is set wrong. Check the case of the password.

I was close :lol:

TRshady
12-16-2003, 10:51 PM
True :lol:
While I&#39;m here, one thing I wanna know:

should dbs be controlled by phpmyadmin or by code?
Im looking for some decent tuts but all the ones I find require you to enter actual code and I have no idea where to add all the code to create tables, add id names etc, as phpmyadmin does this automatically.

TRshady
12-17-2003, 12:12 AM
<bump> people ......

Im using ashosting, have ftp and a cpanel ...... how do I create databses with code? ... only way I see is with the use of cpanel.

I.am
12-17-2003, 02:01 AM
Sorry wasnt here&#33; Have to jump every now and then in the real life :D

Yes use your Control Panel to create a database. You cannot create tables with just codes...

You can also use ssh to login the server and create it but why take the hassle when you have the easier option.

No one will ask you to create a database with code. You have to create using your own control panel and then you can link it wherever you need it.

TRshady
12-17-2003, 08:33 AM
oh ok thanks. :)
Thing is though, I have a few e-books on mysql and they all teach you the coding ..... which is uneeded right as I&#39;ll be using phpmyadmin. :unsure:

So are there any books out that teach you the .... phpmyadmin way of using dbs, of course both methods get the same results but things would be easier if the book simply told the control panel way. :(

Thanks for you help so far. :)

I.am
12-17-2003, 06:04 PM
I have never read books in my life for webdesigning or development :lol: Self made developer I guess. But more towards online learning. I am sure if you search for that on google you will see some useful results. Thats where I always go. phpmyadmin is not that hard. Give it a go&#33;

Even with the book you have for mysql follow it and you will be ok with the coding(commands) part too.

You just have to take your own time ti learn. :)

TRshady
12-17-2003, 06:36 PM
k, thanks. :)
But if I did want to put the code in and follow some of these example, wheres the command promt type box or something I could type the codes in?

I.am
12-17-2003, 06:56 PM
Originally posted by TRshady@17 December 2003 - 13:36
k, thanks. :)
But if I did want to put the code in and follow some of these example, wheres the command promt type box or something I could type the codes in?
You have to connect to your host through ssh or putty. Once logged in the unix server where mysql is installed, you can do all that part of creating databases, tables etc.

Ynhockey
01-05-2004, 02:44 PM
You cannot create tables with just codes...

Not true. Example:



&#036;resource = mysql_query&#40;&#34;CREATE TABLE users &#40;name varchar&#40;32&#41;, pass varchar&#40;16&#41;&#41;;&#34;&#41;;


Would work.

Source: http://sqlcourse.com/create.html

You can also create databases, like mysql_create_db(&#036;database_name); but most likely the server will kick you back with an Access Denied error.

I.am
01-05-2004, 11:40 PM
@Ynhockey, Thanks for bringing that up. I wasn&#39;t quite aware of that. I always used to login through ssh to my host and create database, tables etc. through that.

Never needed to create tables right on the page when the user required. This could be helpful in the future.
:)

Ynhockey
01-06-2004, 06:02 PM
:)

This thing is very helpful for making something like a &#39;create a page&#39; option in your CMS. Usually you&#39;d want it to create a file but often circumstances don&#39;t allow that (if your CHMOD is set to prohibit writing files... but if you CHMOD to allow it then someone could easily hack you), so you can just create a new entry in the database in the form of a table. This is not always necessary but IMO it&#39;s the best way.

I.am
01-06-2004, 10:32 PM
It surely is unsecured if the writing permissions are given to the user. Simple code can be run in php and asp for the very same reason and thus the permissions are set to 755.

But could be helpful if you already authenticate the user and let him/her store things as required.