Jump to content

Recommended Posts

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 :/

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982382
Share on other sites

Sorry guys :) I'll give you the lines next time :P

 

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);

?>

:(

 

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982432
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982491
Share on other sites

Wierd.. nothing displays O0

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.

 

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982558
Share on other sites

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.";
?>

 

:/

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982697
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982701
Share on other sites

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! :P

Link to comment
https://forums.phpfreaks.com/topic/186032-php-mysql-select/#findComment-982929
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.