|
-
April 7th, 2010, 09:55 PM
#1
php - problem with setting up mysql db/table
Im having the most frustrating time trying to figure this out, this script runs great on my private (WAMP) server but not on my hosting server (LAMP). The script is pretty simple, creates a database with a table of 6 fields:
Code:
<?php
$host = "127.0.0.1";
$username = "my_username";
$pwd = "my_password";
if (mysql_connect($host, $username, $pwd))
{
$query = "CREATE DATABASE IF NOT EXISTS weup";
//execute query
if (mysql_query($query))
{
print "Database created successfully!<br />";
//must select db before creating table
if (@mysql_select_db("weup"))
{
$query = "CREATE TABLE IF NOT EXISTS applications(appname VARCHAR(25),
description VARCHAR(200), applink VARCHAR(50), authname VARCHAR(50), authage INT, authloc VARCHAR(40))";
//create the table
if (mysql_query($query)) print "Table created successfully!";
else print "Error creating table";
}
} else print "Error creating database";
mysql_close();
} else print "Unable to connect to " . $host;
?>
-
April 8th, 2010, 10:56 AM
#2
Re: php - problem with setting up mysql db/table
You haven't stated which part of it fails.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 8th, 2010, 11:06 AM
#3
Re: php - problem with setting up mysql db/table
oh im sorry. specifically the 'mysql_query($query)' is whats not working. I know the actual string is good so am i executing it wrongly?
-
April 8th, 2010, 06:02 PM
#4
Re: php - problem with setting up mysql db/table
Which one?
Also...you have a @ in front of mysql_select_db(). That tells it to suppress errors. You might not get a good log report that way.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 8th, 2010, 07:22 PM
#5
Re: php - problem with setting up mysql db/table
both of them, so right now i'm getting outputted "error creating database". and if i take out that first "if(mysql_query())" and just have "mysql_query", then on the next query i get "Error creating table". so basically both
Code:
if (mysql_query($query))
are coming back negative.
-
April 8th, 2010, 07:56 PM
#6
Re: php - problem with setting up mysql db/table
So copy the exact query string into phpMyAdmin. See what that returns.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
April 9th, 2010, 11:21 AM
#7
Re: php - problem with setting up mysql db/table
hey guys, thanks for the replies. after running it through phpMyAdmin I realized the problem had to do with my hosting server not the code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|