Jump to content

Archived

This topic is now archived and is closed to further replies.

something

database

Recommended Posts

I'm new to php and i'm trying to install a news script to use on a page.  It asks me to do this

"Before we begin, we should set up a table in our mysql database.  We will need to following fields:
Name
Subject
Message
Date
ID"

I'm working on a remote server with mysql already set up with everything configured, how do I do this?

Share this post


Link to post
Share on other sites
mysql_connect(...);
mysql_select_db(...);
mysql_query("CREATE `TableName` ....");

Maybe you should read some Mysql tutorials?

Orio.

Share this post


Link to post
Share on other sites
Assuming your host has PHPMyAdmin installed, then you could creat the table and fields using it. Have a look at [url=http://www.phpmyadmin.net]www.phpmyadmin.net[/url] and look through the documentation. If you are following a tutorial, then they probably included a SQL query which will create this for you. You can paste that query into the SQL Query input dialog in PHPMyAdmin which should create the table and fields for you.

Alternatively, you could always take a look at PHPFlashMyAdmin which is a flash based alternative. I have found it to be very useful on hosts that do not have/allow PHPMyAdmin. [url=http://www.tufat.com/script.php?id_num=7]http://www.tufat.com/script.php?id_num=7[/url]

Share this post


Link to post
Share on other sites
I found the program used on my server to setup fields, but what do I do with all these options? (type, length values, Collation, Attributes, Null, Default2, Extra, then the choice between Primary, Index, unique, ---, Fulltext, Comments.  How do I know what to set them to?  Is there a guide anyone could point me to?)

Share this post


Link to post
Share on other sites
There are many MySQL tutorials available on the internet, just Google for them. I have listed one below for you on the official MySQL site which has tonnes of info...

[url=http://dev.mysql.com/doc/refman/5.0/en/creating-tables.html]http://dev.mysql.com/doc/refman/5.0/en/creating-tables.html[/url]

Share this post


Link to post
Share on other sites
I finally have my table setup [img]http://img258.imageshack.us/img258/3740/tablemv8.jpg[/img]


It still gives me a error message, the tutorial gives very little help [url=http://www.phpfreaks.com/quickcode/News-System/523.php]http://www.phpfreaks.com/quickcode/News-System/523.php[/url] what did I miss?

Share this post


Link to post
Share on other sites
I am assuming you replaced the following

[code]
<?php

$db_host = "localhost";
$db_username = "your_db_username";
$db_password = "your_db_password";
$db_name = "your_db_name";

?>
[/code]

with your actual values? If not, it will never work mate... Also, when you get error messages, it is always a good idea to post them with your questions so that it provides us with more information to go on.

Share this post


Link to post
Share on other sites
I just need to be sure about what I'm putting in

$db_host = "localhost";
$db_host = "http://something.com"

$db_username = "your_db_username";
Here do you make up a username or do you have to add it in the table first?

$db_password = "your_db_password";
Same as username.

$db_name = "your_db_name";
What do I enter here?  Just who I want it to say posted it?

Share this post


Link to post
Share on other sites
You will have to find out from your host what the values for these are, my host actually provides these details when I create each database... I have commented next to each one.

[code]
<?php

$db_host = "localhost"; // This is the IP address or fully qualifed domain name of the server on which MySQL is installed
$db_username = "your_db_username"; // This is the username that has been granted rights to modify the database
$db_password = "your_db_password"; // This is the password for the above username
$db_name = "your_db_name"; // This is the name of the database. If you look in the left column of PHPMyAdmin, then you will see the database name above the tables.

?>
[/code]

Share this post


Link to post
Share on other sites
<?php

$db_host = "localhost"; // This is the IP address or fully qualified domain name of the server on which MySQL is installed
$db_host = "http://www.something.com"

$db_username = "your_db_username"; // This is the username that has been granted rights to modify the database
$db_username ="something"

$db_password = "your_db_password"; // This is the password for the above username
$db_password = "admin"

$db_name = "your_db_name"; // This is the name of the database. If you look in the left column of PHPMyAdmin, then you will see the database name above the tables.
$db_name = "some_only"

?>


That’s the approximation of what I changed it to (none of that is the real information) and it still gave me a error message.  Is this setup correctly?

P.S. Is it ok that my table entrees are set to NULL is that ok?

Share this post


Link to post
Share on other sites
I have the submit news working fine, but my new that I'm trying to put on my index keeps showing this...

*edit* removed *edit*

when I uploaded the client/ viewing side on a php instead of html it gave me this error:

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'http' (1) in /home/******/public_html/news.php on line 14
Unknown MySQL server host 'http' (1)

***** replaces a word

Share this post


Link to post
Share on other sites
Just remove the http:// from the $db_host parameter...

[code]
<?php

$db_host = "www.something.com";

?>
[/code]

Share this post


Link to post
Share on other sites
Thank you :) I seem to have solved that, now though it is giveing me this error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user '*******_******'@'**.***.**.**' (using password: YES) in /*****/index.php on line 14
Access denied for user '********'@'**.***.**.**' (using password: YES)

I have the right password in the password area, my username came with a prefix, but my password is as I set it.  Is there a reason why it won't connect?

P.S. I tried adding a local host ("% means allow connection from every Host (IP address)") is there any way to remove the local hosts I added, they didn't form a list below the local host button as I had expected.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.