jmr3460 Posted May 31, 2009 Share Posted May 31, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/ Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 It appears correct. I assume your information is correct as well so try changing <? to <?php. Quote Link to comment https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/#findComment-846022 Share on other sites More sharing options...
jmr3460 Posted May 31, 2009 Author Share Posted May 31, 2009 I changed the <? to <?php and the i>>with the upside down ? disapeared. thanks So you think I got in? How can I verify this I get a white screen when I render this code. Quote Link to comment https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/#findComment-846025 Share on other sites More sharing options...
Ken2k7 Posted May 31, 2009 Share Posted May 31, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/#findComment-846028 Share on other sites More sharing options...
jmr3460 Posted May 31, 2009 Author Share Posted May 31, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/#findComment-846031 Share on other sites More sharing options...
jmr3460 Posted May 31, 2009 Author Share Posted May 31, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160321-solved-did-i-get-in-or-not/#findComment-846033 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.