aruns Posted February 21, 2008 Share Posted February 21, 2008 Hai guys., Now i am creating a shopping cart but we had this Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mastern/public_html/newadmin/login.php on line 13 This is the script $result = mysql_query("select * from" . ADMIN_LOGIN . "where email='$email' and password = '$pass'"); $res = mysql_fetch_array($result); $ad_user = $res['user']; $ad_pass = $res['password']; Thanks all Arun Quote Link to comment Share on other sites More sharing options...
schilly Posted February 21, 2008 Share Posted February 21, 2008 MYSQL error somewhere. Try this and see what error it gives you. $result = mysql_query("select * from" . ADMIN_LOGIN . "where email='$email' and password = '$pass'") or die('mysql error: ' . mysql_error()); $res = mysql_fetch_array($result); Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 21, 2008 Share Posted February 21, 2008 nevermind... Quote Link to comment Share on other sites More sharing options...
Barand Posted February 21, 2008 Share Posted February 21, 2008 As there is no space after "from" or before "where" the script will read select * fromtablenamewhere email - ...... Quote Link to comment Share on other sites More sharing options...
schilly Posted February 21, 2008 Share Posted February 21, 2008 ah right. good eyes. Quote Link to comment Share on other sites More sharing options...
aruns Posted February 22, 2008 Author Share Posted February 22, 2008 Hi Barand, Thanks for replied., its working i am correct the space after from and before where.. And one More what is .inc or .inc.php file and why they use.. Thanks Arun Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 22, 2008 Share Posted February 22, 2008 They are include files... For example you write your db login in a separate file and then to include that file in your script as <? include ('dblogin.inc.php'); ?> its gonna include all the information from that file. Its better practice then putting it your page script incase you mess up and then someone can see your php script and then see your db username and password. Also stops your from declaring the db login info on every page, you just need do include ('dblogin.inc.php'); Quote Link to comment Share on other sites More sharing options...
aruns Posted February 22, 2008 Author Share Posted February 22, 2008 Hi vicodin , Thaks for reply . I understood but still little doubt when i am put database connection script like connection.inc.php. where can i include this file for whole project and how it is possible. Thanks Arun Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 22, 2008 Share Posted February 22, 2008 just put it on every one of your pages that needs db connect. Quote Link to comment Share on other sites More sharing options...
aruns Posted February 22, 2008 Author Share Posted February 22, 2008 you told me "stops your from declaring the db login info on every page, you just need do include ('dblogin.inc.php');".i try to do this just i put db connection and saved db.inc.php included it in index.php. but the other pages says Warning: mysql_query() [function.mysql-query]: Access denied for user 'mastern'@'localhost' (using password: NO) in /home/mastern/public_html/newadmin/account.php on line 40 Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 22, 2008 Share Posted February 22, 2008 this is what i have in my db include. <?php mysql_connect("localhost", "username", "pass") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted February 22, 2008 Share Posted February 22, 2008 you told me "stops your from declaring the db login info on every page, you just need do include ('dblogin.inc.php');".i try to do this just i put db connection and saved db.inc.php included it in index.php. but the other pages says Warning: mysql_query() [function.mysql-query]: Access denied for user 'mastern'@'localhost' (using password: NO) in /home/mastern/public_html/newadmin/account.php on line 40 It means either: 1) The user doesn't exist. 2) The user does exist but the password is wrong. 3) The user does exist but does not have access to that specific database which you chose. Quote Link to comment Share on other sites More sharing options...
aruns Posted February 22, 2008 Author Share Posted February 22, 2008 Thanks.I know but i saw a zencart script they was not included db connection file or configure file but the page sucessfully run how this is possible Quote Link to comment Share on other sites More sharing options...
vicodin Posted February 22, 2008 Share Posted February 22, 2008 No matter how you do it there has to be some kind of validation for the db... it could be built into the functions. Quote Link to comment Share on other sites More sharing options...
aruns Posted February 22, 2008 Author Share Posted February 22, 2008 i understood.. Thanks Arun Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 22, 2008 Share Posted February 22, 2008 Try this in your include file: $host = "localhost"; $usr = "username"; $pwd = "password"; $db = "database_name"; and then include the file in the page in question and do this to start your db query: $connection = mysql_connect($host,$usr,$pwd); $query= mysql_db_query($db, "SELECT * from table", $connection);} Quote Link to comment 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.