Jump to content

[SOLVED] Did I get in or not?


jmr3460

Recommended Posts

I am having some issues with a script that I am working with. I am going to start with the first part of the script and work my way to the end. I don't know if I am actually getting into the db. When I run this file I get this on browser>

 



 

This is my code:

<?

/**
* Connect to the mysql database.
*/
$host = "localhost";
$user = "username";
$password = "password";
$database = "database_name";

$conn = mysql_connect($host, $user, $password) or die("could nit get in" . mysql_error() );

mysql_select_db($database, $conn) or die("could nit get in db" . mysql_error());

?>

 

Can anyone help me? Thanks for any knowledge.

Link to comment
https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/
Share on other sites

Just run some SQL -

 

<?php
/**
* Connect to the mysql database.
*/
$host = "localhost";
$user = "username";
$password = "password";
$database = "database_name";

$conn = mysql_connect($host, $user, $password) or die("could nit get in" . mysql_error() );
mysql_select_db($database, $conn) or die("could nit get in db" . mysql_error());

$sql = 'SHOW TABLES;';
$results = mysql_query($sql) or die('sql failed - ' . mysql_error());
while ($row = mysql_fetch_assoc($results)) var_dump($row);

 

If you see something other than errors, then it works. :)

I tried this:

<?php

/**
* Connect to the mysql database.
*/
$host = "localhost";
$user = "simplic5_jmr3460";
$password = "freedom98714";
$database = "simplic5_users";

$conn = mysql_connect($host, $user, $password) or die("could not get in" . mysql_error() );

mysql_select_db($database, $conn) or die("could not get in db" . mysql_error());

   $q = "select username from users where username = '$username'";
   $result = mysql_query($q,$conn);
echo "$result";
?>

 

I got this on my browser:

Resource id #2

OK I tried what you requested and I got this:

 

 

array(1) { ["Tables_in_simplic5_users"]=>  string(10) "auth_users" } array(1) { ["Tables_in_simplic5_users"]=>  string(5) "users" }

 

 

Looks like I am getting in. I have two tables users and auth_users. Thanks for all of your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.