PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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
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:
<?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.";
}
?>
Last edited by suthie on Sun Jun 10, 2007 7:53 am, edited 2 times in total.
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.
<?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
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)