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.

Recommended Answers

All 4 Replies

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

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

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?

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.