• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Help] Problem with my PHP Script

Elite Diviner
Joined
Jan 26, 2006
Messages
483
Reaction score
5
Hi,

I have tried to make a php script to change something in sql.

When I try to run it in internet browser I see this error:

My Error

Code:
Parse error: parse error, unexpected T_ELSE in C:\AppServ\www\travia\travia_do_account.php on line 44

My Travia_Config.php:

Code:
<?
//MSSQL settings
$user = 'MYUSERHERE';
$haslo = 'MYPASSWORDHERE';
$nazwabazy = "Game";
$hostbazy = "localhost";
?>

My travia_do_account.php:

Code:
<?php
include 'travia_config.php';
$tabelka = '<table>
<form action=travia_do_account.php method=post>
<tr><td>Charname</td><td><input type=text name=login value="'.$_POST['login'].'"></td></tr>
<tr><td>Class</td><td><input type=text name=pass></td></tr>
<tr><td><input type=submit value="Change Job"></td><td><input type=reset value="Clear fields"></td></tr>
</form>
</table>';

if($reg_open AND isset($_POST['login']))
{
$conn=@mssql_connect($hostbazy,$user,$haslo) or die("<b>Critical Error</b><br>MSSQL server is offline OR I can't Access to it !");
@mssql_select_db($nazwabazy, $conn) or die("<b>Critical Error</b><br>Database don't exists OR I can't Access to it !");

$login = $_POST['login'];
$pw = $_POST['pass'];

$login = trim($login);
$pw = trim($pw);

if(ereg("[^0-9a-zA-Z_-]", $login))
	{
	echo 'Please do use only 0-9 a-Z';
	echo '<br>'.$tabelka;
	}
elseif (ereg("[^0-9a-zA-Z_-]", $pw))
	{
	echo 'Please do use only 0-9 a-Z';
	echo '<br>'.$tabelka;
	}
elseif (empty($login) || empty($pw))
	{
	echo 'Please do use only 0-9 a-Z<br>'.$tabelka;
	}
else
	{
	$resultx = mssql_query("SELECT LOWER(UT_USERID) FROM CHARTABLE 
	WHERE LOWER(UT_USERID) = ('$login')") or die;
		}
		{
		echo 'No valed charname<br>'.$tabelka;
		}
	else 
		{
		mssql_query("INSERT INTO CHARTABLE (UT_USERID,CT_CLASS) VALUES ('".$login."','".$pw."',convert(binary,'".$login."');
		echo "Job Is Changed Succesfully";
		}
	}
?>
<BR>
<a><b>Created By: Darkco</b></a>
</BR>

My MSSQL Query script works fine Now I want this in PHP:


Code:
USE Game

UPDATE CHARTABLE
SET CT_CLASS = NUMBERHERE
WHERE ( CT_USERID = 'CHARNAMEHERE' )

Please help me

Thanks....
 
Last edited:
Newbie Spellweaver
Joined
Jan 23, 2005
Messages
45
Reaction score
3
the line below these:
WHERE LOWER(UT_USERID) = ('$login')") or die;
}

You should add an if or something like that,
You open a codeblock there with {}
without some kind of expression and after that codeblock you use else,
how can the compiler guess what you want todo?
 
Elite Diviner
Joined
Jan 26, 2006
Messages
483
Reaction score
5
now i got:

Code:
Parse error: parse error, unexpected T_STRING in C:\AppServ\www\travia\travia_do_account.php on line 46
 
Initiate Mage
Joined
Feb 27, 2006
Messages
4
Reaction score
0
Darkc0 said:
now i got:

Code:
Parse error: parse error, unexpected T_STRING in C:\AppServ\www\travia\travia_do_account.php on line 46

What did you done? please put here the code for this new error
 
Elite Diviner
Joined
Jan 26, 2006
Messages
483
Reaction score
5
Code:
WHERE LOWER(UT_USERID) = ('$login') or die;

I maked this of that line... then i got this error:

Code:
Parse error: parse error, unexpected T_STRING in C:\AppServ\www\travia\travia_do_account.php on line 46
 
Divine Celestial
Loyal Member
Joined
Nov 11, 2004
Messages
810
Reaction score
0
Do you ppl know that there's a
PHP:
 tag to highlight your code and make it a heck of alot easier to read?

[N]asser` ~ Out
 
Custom Title Activated
Loyal Member
Joined
Aug 8, 2004
Messages
3,892
Reaction score
20
Replace
PHP:
else
	{
	$resultx = mssql_query("SELECT LOWER(UT_USERID) FROM CHARTABLE 
	WHERE LOWER(UT_USERID) = ('$login')") or die;
		}
		{
		echo 'No valed charname<br>'.$tabelka;
		}
	else 
		{
		mssql_query("INSERT INTO CHARTABLE (UT_USERID,CT_CLASS) VALUES ('".$login."','".$pw."',convert(binary,'".$login."');
		echo "Job Is Changed Succesfully";
		}
	}

With

PHP:
else  {
  $resultx = mssql_query("SELECT LOWER(UT_USERID) FROM CHARTABLE 
                 WHERE LOWER(UT_USERID) = ('$login')") or die;
  if(mssql_num_rows($resultx) > 0)
	echo 'No valed charname<br>'.$tabelka;
  else  {
    $query = mssql_query("INSERT INTO CHARTABLE (UT_USERID,CT_CLASS) VALUES ('$login', '$pw', convert(binary,'$login'))");
  echo "Job Is Changed Succesfully";
  }
}
 
Back
Top