zero_ZX Posted December 22, 2009 Share Posted December 22, 2009 hi, i have this code: <?php session_start(); // dBase file include "config.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and FG-Pass."); } // Create query $id = "SELECT member_id FROM `members` " ."WHERE `name`='".$_POST["username"]."' " $q = "SELECT * FROM `members` " ."WHERE `name`='".$_POST["username"]."' " ."AND `p_locked`=0 " ."AND SELECT field_13 FROM `pfields_content` " ."WHERE `id`='".$id."' " ."AND WHERE `field_13`=('".$_POST["password"]."') " //`pass`=('".$_POST["password"]."') " ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { // Login good, create session variables $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); // Redirect to member page Header("Location: shop.php"); } else { // Login not successful die("Sorry, could not log you in. Wrong login information. <br> Or your fg has been locked. Please contact Smilie."); } } else { //If all went right the Web form appears and users can log in echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "FG-Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?> Error: Parse error: syntax error, unexpected T_VARIABLE in /home/b2ku00/public_html/fg/login.php on line 17 I don't get this.. I can't find any error in line 17 :/ Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/ Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 // Create query $id = "SELECT member_id FROM `members` " ."WHERE `name`='".$_POST["username"]."' " is missing its ; Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982381 Share on other sites More sharing options...
premiso Posted December 22, 2009 Share Posted December 22, 2009 Next time please point out line 17, as it is annoying having to find it, especially since we are helping you, you should help us. // Create query $id = "SELECT member_id FROM `members` " ."WHERE `name`='".$_POST["username"]."' "; You were missing the semicolon there. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982382 Share on other sites More sharing options...
Maq Posted December 22, 2009 Share Posted December 22, 2009 You should really get into the habit of properly formatting and indenting your code. As of now, it's all over the place and makes everything exponentially harder to debug and maintain. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982410 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Sorry guys I'll give you the lines next time Any way, i guess that's time is now, cause for some reason i think my include is failing.. When trying to login, php returns: Warning: mysql_query() [function.mysql-query]: Access denied for user 'b2ku00'@'localhost' (using password: NO) in /home/b2ku00/public_html/fg/login.php on line 26 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/b2ku00/public_html/fg/login.php on line 26 ."LIMIT 1"; // Run query $r = mysql_query($q); This is my database configuration: <?php // SQL info $host = "lpsql01.lunariffic.com"; $user = "b2ku00_admin"; $pass = "****"; $db = "b2ku00_forum"; // Setup connection $ms = mysql_pconnect($host, $user, $pass); if ( !$ms ) { echo "Error connecting to database.\n"; } // Select DB mysql_select_db($db); ?> Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982432 Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 Ensure you have the right permissions on your database for that user.. The error you are receiving says it all Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982435 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Error says: 'b2ku00'@'localhost' (using password: NO) 1) not using that user 2) not that host 3) i am using password Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982452 Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 mysql_select_db($db,$ms) or die(mysql_error()); replaces mysql_select_db($db); And let us know the outcome. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982468 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Same.. browsing the config file returns nothing.. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982481 Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 So you changed that line and still nothing? Has the error changed? Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982483 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Yea i changed the line, but no new output when trying to view the config file in the browser, and error on the login.php is the same. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982485 Share on other sites More sharing options...
premiso Posted December 22, 2009 Share Posted December 22, 2009 Are you sure you are accessing the correct config.php? Try this: <?php // SQL info $host = "lpsql01.lunariffic.com"; $user = "b2ku00_admin"; $pass = "****"; $db = "b2ku00_forum"; // Setup connection $ms = mysql_pconnect($host, $user, $pass) or trigger_error("Unable to connect: " . mysql_error()); if ( !$ms ) { echo "Error connecting to database.\n"; } // Select DB mysql_select_db($db) or trigger_error("Database not selected: " . mysql_error()); echo "The database has been selected."; ?> And see if the echo statement echos or if there is an error. If there is no "The database has been selected." echo'ed you are modifying / including the wrong file and you need to look at that to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982491 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Wierd.. nothing displays but my php.ini have display_errors = On display_startup_errors = on :/ Nothing display when using a bad password either.. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982553 Share on other sites More sharing options...
Maq Posted December 22, 2009 Share Posted December 22, 2009 Wierd.. nothing displays but my php.ini have display_errors = On display_startup_errors = on :/ Nothing display when using a bad password either.. After making changes to php.ini you have to restart apache, but just to be safe, you can add: ini_set ("display_errors", "1"); error_reporting(E_ALL); directly after your opening PHP tag, to temporarily turn error_reporting on max. Is your config file in the same directory you're including it from? Are you local? If so, you can try to login manually through a terminal. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982558 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Hmm... Now im getting this error: Fatal error: Call to undefined function phpini_set() in /home/b2ku00/public_html/fg/inc/config.php on line 1 <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982563 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 Up! Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982670 Share on other sites More sharing options...
Maq Posted December 22, 2009 Share Posted December 22, 2009 Up! Is that a form of bumping? Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982672 Share on other sites More sharing options...
premiso Posted December 22, 2009 Share Posted December 22, 2009 Given this: phpini_set() you have your code most likely like so: <?phpini_set() Make sure that is not what is going on etc. If it is separate it out like this: <?php ini_set() Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982694 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 I have linebreaks like this: <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); // SQL info $host = "lpsql01.lunariffic.com"; $user = "b2ku00_admin"; $pass = "**"; $db = "b2ku00_forum"; // Setup connection $ms = mysql_pconnect($host, $user, $pass) or trigger_error("Unable to connect: " . mysql_error()); if ( !$ms ) { echo "Error connecting to database.\n"; } // Select DB mysql_select_db($db) or trigger_error("Database not selected: " . mysql_error()); echo "The database has been selected."; ?> :/ Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982697 Share on other sites More sharing options...
premiso Posted December 22, 2009 Share Posted December 22, 2009 Well your code somewhere is messed up and you do not know, either in translation (uploading it to the server) or something. As the only way I can see to produce that error is a mistake like this: <? phpini_set(); Other than that I do not know how your files are setup and where that error is coming from. But given that it is on line one, maybe the editor is not really breaking out the lines. Make sure you are editing the proper file and that it is saving in the right spot. Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982701 Share on other sites More sharing options...
teynon Posted December 22, 2009 Share Posted December 22, 2009 What program are you using to modify your code? Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982703 Share on other sites More sharing options...
zero_ZX Posted December 22, 2009 Author Share Posted December 22, 2009 I'm using notepad ++ Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982705 Share on other sites More sharing options...
dbradbury Posted December 22, 2009 Share Posted December 22, 2009 sorry didnt see the second page! lol Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982748 Share on other sites More sharing options...
Maq Posted December 23, 2009 Share Posted December 23, 2009 sorry didnt see the second page! lol Hehe, it's OK, that's what the modify button is for I'm using notepad ++ Any luck? Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982801 Share on other sites More sharing options...
zero_ZX Posted December 23, 2009 Author Share Posted December 23, 2009 Not at all lol, this is wierd: <?php /* // SQL info $host = "lpsql01.lunariffic.com"; $user = "b2ku00_admin"; $pass = "deCheepiji"; $db = "b2ku00_forum"; // Setup connection $ms = mysql_pconnect($host, $user, $pass) or trigger_error("Unable to connect: " . mysql_error()); if ( !$ms ) { echo "Error connecting to database.\n"; } // Select DB mysql_select_db($db) or trigger_error("Database not selected: " . mysql_error()); echo "The database has been selected."; */ echo "The database has been selected."; ?> returns: Parse error: syntax error, unexpected T_ECHO in /home/b2ku00/public_html/fg/inc/config.php on line 1 only lined not commented: echo "The database has been selected."; (and the php tags) Common! Quote Link to comment https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982929 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.