Page 1 of 2

nothing works... host problem? *solved*

Posted: Sat Jun 09, 2007 3:42 pm
by suthie
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am trying to do a user login system just as a test with justfree.com....

nothing i do works. I have resorted to literally copying and pasting stuff i googles and just putting in my info. i can't get the mysql database to work... is it a host problem? or something dumb i am overlooking?

here is one of the scripts i tried using that didn't work

Code: Select all

<?

/**
 * Connect to the mysql database.
 */
$conn = mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db('penguinflash_vibe', $conn) or die(mysql_error());

CREATE TABLE users (
    username varchar(30),
    password varchar(32));


?>

i did that and then went to the php myadmin thing and there was no table in the database. what is the issue?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]


edit:
here is the code that made it work:

Code: Select all

<?php

// set your infomation.
$dbhost='localhost';
$dbusername='david';
$dbuserpass='mypassword';
$dbname='test';

// connect to the mysql database server.
$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass);
echo "success in database connection.";

// select the specific database name we want to access.
if (!mysql_select_db($dbname)) die(mysql_error());
echo "success in database selection.";

// add a table to the selected database
$result="CREATE TABLE users (username VARCHAR(25), password VARCHAR(25), email VARCHAR(30))";
if (mysql_query($result)){
echo "success in table creation.";
} else {
echo "no table created.";
}

?>

Posted: Sat Jun 09, 2007 4:00 pm
by Ambush Commander
Are any errors coming up?

Posted: Sat Jun 09, 2007 4:07 pm
by suthie
no

its just a blank screen

Posted: Sat Jun 09, 2007 4:11 pm
by Ambush Commander
Well, let's fix the syntax error then.

Run this, will ya?

Code: Select all

<?php

error_reporting(E_ALL);

/**
* Connect to the mysql database.
*/
$conn = mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db('penguinflash_vibe', $conn) or die(mysql_error());

$sql = 'CREATE TABLE users (
username varchar(30),
password varchar(32));';


?>
Tell me what you get.

Posted: Sat Jun 09, 2007 4:39 pm
by suthie
the same thing happens...

i get a blank screen and there is still no table in the database.

Posted: Sat Jun 09, 2007 4:41 pm
by feyd
The code posted so far creates no output nor does it call any functions that would make the SQL run at the database. It should be a nicely blank screen.

Posted: Sat Jun 09, 2007 4:53 pm
by suthie
very true....

okay so now i ran this:

Code: Select all

<?php

// set your infomation.
$dbhost='localhost';
$dbusername='username';
$dbuserpass='mypassword';
$dbname='test';

// connect to the mysql database server.
$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass);
echo "success in database connection.";

// select the specific database name we want to access.
$dbname=$dbusername."_".$dbname;
if (!mysql_select_db($dbname)) die(mysql_error());
echo "success in database selection.";

// add a table to the selected database
$result="CREATE TABLE address_book (first_name VARCHAR(25), last_name VARCHAR(25), phone_number VARCHAR(15))";
if (mysql_query($result)){
echo "success in table creation.";
} else {
echo "no table created.";
}

?>
and got this:
success in database connection.Access denied for user 'penguinflash_admin'@'localhost' to database 'penguinflash_admin_users'

why would it deny me access? i know the user and password i put in are right because i used them to check if the table had been created in php myadmin

Posted: Sat Jun 09, 2007 4:58 pm
by thiscatis
does your database user has all the privileges?

Posted: Sat Jun 09, 2007 4:59 pm
by suthie
yes. the user has every privilege possible.

is it wrong to leave the host at "localhost"? should that be the name of the website or something?

Posted: Sat Jun 09, 2007 4:59 pm
by .Stealth
looks like you are not allowed to create tables with your priveleges which is abit stupid

Posted: Sat Jun 09, 2007 5:04 pm
by suthie
yeah that is really stupid if it is the case. its not like im a user on somebody else's site. this is supposed to be my account on justfree.com

is there another possibility?

ive created a table from within php myadmin before and it worked there... but then when i tried to use that table i couldnt put data in or take it out. (thats why im trying to create a table with straight php code now)

Posted: Sat Jun 09, 2007 5:06 pm
by .Stealth
suthie wrote:yes. the user has every privilege possible.

is it wrong to leave the host at "localhost"? should that be the name of the website or something?

didnt they give you any details?
localhost might be a different database your trying to connect to.

you will probably need a url as the database might not be hosted on the local host.

Posted: Sat Jun 09, 2007 5:11 pm
by suthie
I just found a justfree.com "how to make a website" tutorial. it says that "localhost" is correct. now what?

Posted: Sat Jun 09, 2007 5:13 pm
by .Stealth
suthie wrote:they never gave me any details... what might it be?

i tried using "justfree" also.

i searched the FAQ and found nothing.
could be anything.

mysql1.example.com

check your emails.

Posted: Sat Jun 09, 2007 5:15 pm
by suthie
I just verified that "localhost" is correct. (sorry i edited the old post instead of posting a new one)

what other possibilities are there?