Jump to content

Problemas com PHP/MySQL - Ajuda


xcubic

Recommended Posts

Escrevi estas linhas :

<?php 

$hostname = "***"; 
$user = "***"; 
$password = "***";
$db = "***";
echo "<br>Hostname: ",$hostname;
echo "<br>User: ",$user;
echo "<br>Password: ",$password;
echo "<br>Database Name: ",$db;
$var_test=1;


$connect = mysql_connect($hostname, $user, $password);
if (!($connect)) 
{
echo "<br><br>Status: Error, NOT connected!","<br>"; 
$var_test=0;
}
else 
echo "<br><br>Status: Conected to $hostname!";
      
if ($var_test==1)     
{
$query_create_db = "CREATE DATABASE $db";
$create_db = mysql_query($query_create_db,$connect);
if($create_db==1)
	echo "<br>Status : Database created!","<br>";
else
	{
	echo "<br>Status : Database NOT created!";
	$var_test=0;  
        }
}
else{}

if ($var_test==1)     
{
$db_select = mysql_select_db($db, $connect);
if($db_select==1)
	echo "<br>Status : Database selected!","<br>";
else
	{
	echo "<br>Status : Database NOT selected!";
	$var_test=0;  
	}
}
else{}

if ($var_test==1)     
{
$query_create_tbl_login = "CREATE TABLE 'login' (
	codigo INT AUTO_INCREMENT PRIMARY KEY,
	nome VARCHAR(40),
	email VARCHAR(50),
	nick VARCHAR(40),
	password VARCHAR(50)
	)";
$create_tbl_login = mysql_query($query_create_tbl_login,$connect);
if($create_tbl_login==1)
	echo "<br>Status : Database LOGIN created!","<br>";
else
	{
	echo "<br>Status : Database NOT selected!";
	$var_test=0;  
	}
 }
else{}
      		        
echo "<br><br>END";
?>

mas o resultado é:

Hostname: ***
User: ***
Password: ***
Database Name: ***

Status: Conected to ***!
Status : Database created!

Status : Database selected!

Status : Database NOT selected!

END

e não entendo onde tá o problema.agradecia uma pequena ajuda...Bigado

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.