0

Hello folks,
I'm getting the error message "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /var/www/login.php on line 9". I've been at it for hours and my eyes are starting to bleed, I would greatly appreciate a code-weary traveller could spot my mistake. Here's the first 10 lines of my page. The inconspicuous.inc file just defines $host, $password etc.

<?php
session_start();
include("inconspicuous.inc");
switch (@$_POST['do'])
{
	case "login":
		$connect=mysql_connect($host, $user, $password, $database) or die("Couldn't connect to server.");
		$sql="SELECT loginID FROM member WHERE loginID='$_POST[fusername]'";
		$result=mysql_query($connect, $sql) or die(mysql_error() "Query FAIL.");
		$num=mysql_num_rows($result);

Thanks in advance,
Darren.

2
Contributors
4
Replies
9
Views
7 Years
Discussion Span
Last Post by dreinzy
0

You are missing a dot between mysql_error and your string to concatenate them.

$result=mysql_query($connect, $sql) or die(mysql_error() . "Query FAIL.");
0

Thanks pritaeas,
but now I'm getting "mysql_query(): supplied argument is not a valid MySQL-Link resource in /var/www/login.php on line 9".

0

I've tried switching the order in the query on the problematic line i.e.

$result=mysql_query($sql, $connect) OR die(mysql_error() . "Query FAIL.");

as suggested to someone else on another forum. It tells me I'm not connected to a Database. I get the same message if I get rid of the $connect too:

mysql_connect($host, $user, $password, $database) or die("Couldn't connect to server.");
$sql="SELECT loginID FROM member WHERE loginID='$_POST[fusername]'";
$result=mysql_query($sql) or die(mysql_error() "Query FAIL.");

Does this mean anything? Maybe the problem is elsewhere?

0

Got it working!
I had the $connect and $sql in the wrong order, I also needed mysql_select_db(). Durp.

<?php
session_start();
include("inconspicuous.inc");
switch (@$_POST['do'])
{
	case "login":
	$connect=mysql_connect($host, $user, $password, $database) or die("Couldn't connect to server.");
	$sql="SELECT loginID FROM member WHERE loginID='$_POST[fusername]'";
	mysql_select_db(members);
	$result=mysql_query($sql, $connect) or die(mysql_error() . "Query FAIL.");
	$num=mysql_num_rows($result);
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.