Jump to content


Photo

database


  • Please log in to reply
12 replies to this topic

#1 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 22 October 2006 - 08:49 PM

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?

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 22 October 2006 - 08:59 PM

mysql_connect(...);
mysql_select_db(...);
mysql_query("CREATE `TableName` ....");

Maybe you should read some Mysql tutorials?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 22 October 2006 - 09:14 PM

Assuming your host has PHPMyAdmin installed, then you could creat the table and fields using it. Have a look at www.phpmyadmin.net 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. http://www.tufat.com...pt.php?id_num=7

#4 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 22 October 2006 - 09:18 PM

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?)

#5 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 22 October 2006 - 09:31 PM

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...

http://dev.mysql.com...ing-tables.html

#6 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 22 October 2006 - 10:05 PM

I finally have my table setup Posted Image


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

#7 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 22 October 2006 - 10:09 PM

I am assuming you replaced the following

<?php

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

?>

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.

#8 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 22 October 2006 - 10:19 PM

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?

#9 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 22 October 2006 - 10:27 PM

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.

<?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.

?>


#10 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 22 October 2006 - 11:41 PM

<?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?

#11 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 23 October 2006 - 02:43 AM

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

#12 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 23 October 2006 - 08:48 AM

Just remove the http:// from the $db_host parameter...

<?php

$db_host = "www.something.com";

?>


#13 something

something
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 23 October 2006 - 11:02 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users