• 0

[Help] Parse Error


Question

Well I will first of all post the error...

Parse error: parse error, unexpected T_VARIABLE in C:\Program Files\Apache\Apache2\htdocs\websitetest\register.php on line 11

And here is the code...

(Register.html)

<HTML>
<HEAD>
<TITLE>Register</TITLE>
</HEAD>
<BODY>

// Form to register with

<FORM METHOD="post" ACTION="register.php">;p>Name:
<INPUT TYPE="text" Name="Name" Size=30> MAXLENGTH=25</p>
<p>Password:
<INPUT TYPE="text" Name="Password" Size=30> MAXLENGTH=12</p>
<p>Confirm Password:
<INPUT TYPE="text" Name="CPassword" Size=30> MAXLENGTH=12</p>
<p>E-Mail:
<INPUT TYPE="text" Name="EMail" Size=30> MAXLENGTH=50</p>
<p>Website:
<INPUT TYPE="text" Name="Website" Size=30> MAXLENGTH=50</p>
<p>Location:
<INPUT TYPE="text" Name="Location" Size=30> MAXLENGTH=50</p>
<p>Occupation:
<INPUT TYPE="text" Name="Occupation" Size=30> MAXLENGTH=50</p>
<p>ICQ:
<INPUT TYPE="text" Name="ICQ" Size=30> MAXLENGTH=10</p>
<p>MSN Address:
<INPUT TYPE="text" Name="MSN" Size=30> MAXLENGTH=25</p>
<p>AIM Address:
<INPUT TYPE="text" Name="AIM" Size=30> MAXLENGTH=25</p>
<p>Yahoo Address:
<INPUT TYPE="text" Name="Yahoo" Size=30> MAXLENGTH=25</p>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Submit"></p>
</FORM>
</BODY>
</HTML>

(Register.php)

<?
	if ((!$name) || (!$Password) || (!$CPassword) || (!$EMail)) {
  header( "Location: register.html");
  exit;
	}
$db_name = "websitetest";
$table_name = "$name";

$connection = @mysql_connect("localhost", "websitetest", "") or die("couldn't Connect to Database.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "INSERT INTO $name (Name,Password,CPassword,EMail,Website,Location,Occupation,ICQ,MSN,AIM,Yahoo) VALUES ("$Name",password($Password),"$CPassword","$EMail","$Website","$Location","$Occupation","$ICQ","$MSN","$AIM","$Yahoo")";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
?>

<HTML>
<HEAD>
	<TITLE>Register</TITLE>
</HEAD>
<BODY>
	<P><STRONG>Name:</STRONG>
  <? print "$Name"; ?></P>
	<P><STRONG>Password:</STRONG>
  <? print "$Password"; ?></P>
	<P><STRONG>E-Mail:</STRONG>
  <? print "$EMail"; ?></P>
	<P><STRONG>Website:</STRONG>
  <? print "$Website"; ?></P>
	<P><STRONG>Location:</STRONG>
  <? print "$Location"; ?></P>
	<P><STRONG>Occupation:</STRONG>
  <? print "$Occupation"; ?></P>
	<P><STRONG>ICQ:</STRONG>
  <? print "$ICQ"; ?></P>
	<P><STRONG>MSN Address:</STRONG>
  <? print "$MSN"; ?></P>
	<P><STRONG>AIM Address:</STRONG>
  <? print "$AIM"; ?></P>
	<P><STRONG>Yahoo Address:</STRONG>
  <? print "$Yahoo"; ?></P>
</BODY>
</HTML>

Do you know what is causing this?

(And yes I am not using a database password)

Thanks,

Esoteric

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/
Share on other sites

19 answers to this question

Recommended Posts

  • 0

Sorry, my mistake, you need to put a \ infront of the quotes so they don't get treated as the end of the string.

$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");

$sql = "INSERT INTO $name (Name,Password,CPassword,EMail,Website,Location,Occupation,ICQ,MSN,AIM,Yahoo) VALUES (\"$Name\",password($Password),\"$CPassword\",\"$EMail\",\"$Website\",\"$Location\",\"$Occupation\",\"$ICQ\",\"$MSN\",\"$AIM\",\"$Yahoo\")";

$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1817616
Share on other sites

  • 0

One more time:

$sql = "INSERT INTO $name (Name,Password,CPassword,EMail,Website,Location,Occupation,ICQ,MSN,AIM,Yahoo) VALUES ('$Name',password('$Password'),'$CPassword','$EMail','$Website','$Location','$Occupation','$ICQ','$MSN','$AIM','$Yahoo')";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query. Reason: " . mysql_error() );

I changed all those to single quotes, and added Reason: " . mysql_error() to the die for the query so you'd get better error results.

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1819354
Share on other sites

  • 0

OK, I get it now.

The problem would appear to be here:

if ((!$name) || (!$Password) || (!$CPassword) || (!$EMail)) {
 header( "Location: register.html");
 exit;
}

It's not finding some or all of those. First off, $name should be $Name to fit your form (it *probably* wouldn't matter) - even better would be to make all data names lowercase as this is generally the used method.

At a guess the problem is that your server isn't set up to automatically set passed data. Try this at the start:

$name = $_POST['Name'];
$password = $_POST['Password'];
$cpassword = $_POST['CPassword'];
// Continue for all 12 or so bits of data

if ((!$name) || (!$password) || (!$cPassword) || (!$email)) {
 header( "Location: register.html");
 exit;
}

// And so on...

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1819653
Share on other sites

  • 0
  Mr magoo said:
is this intentional?

<html>
<INPUT TYPE="text" Name="ICQ" Size=30> MAXLENGTH=10</p>
<INPUT TYPE="text" Name="ICQ" Size=30 MAXLENGTH="10"> </p> <!-- was this what you intended? --!>
</html>

No that wasn't intentional, however I did notice it about the time when I first posted this topic and so I changed the code, just forgot to update it on here...

And I will try that timdorr when i get home (I am at school currently)

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1824719
Share on other sites

  • 0
  timdorr said:
How about:

if (($name == '') || ($Password == '') || ($CPassword == '') || ($EMail == '')) {

header( "Location: register.html");

exit;

}

Tried that, however instead of recycling, it gave me the parse error again...

Parse error: parse error, unexpected T_VARIABLE in C:\Program Files\Apache\Apache2\htdocs\websitetest\register.php on line 11

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1826340
Share on other sites

  • 0

I haven't been using PHP/MySQL long, but don't you have to set the POST data to variables first?

try putting the following before you test for empty variables:

$name = $_POST['name'];

$Password = $_POST['Password'];

$CPassword = $_POST['CPassword'];

$EMail = $_POST['EMail];

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1866461
Share on other sites

  • 0

I didn't notice this at first:

$sql = "INSERT INTO $name ...

It looks like you want to have a different table for every username. Since the table you want to add to is based on user input, your INSERT query is inserting into a non-existant table. You'd have to create a new table every time.

It would be a lot easier to keep everything in one table (assuming you were trying to put them in separate tables). So just replace $name in that instance with whatever you would call the table, or better yet, put the name after "$table_name = ".

If I confused you, here's what I'm telling you to try:

<?
$Name = $_POST['name'];
$Password = $_POST['Password'];
$CPassword = $_POST['CPassword'];
$EMail = $_POST['EMail];

if ((!$Name) || (!$Password) || (!$CPassword) || (!$EMail)) {
 header( "Location: register.html");
 exit;
}
$db_name = "websitetest";
$table_name = "your_table_name";

$connection = @mysql_connect("localhost", "websitetest", "") or die("couldn't Connect to Database.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "INSERT INTO $table_name (Name,Password,CPassword,EMail,Website,Location,Occupation,ICQ,MSN,AIM,Yahoo) VALUES ('$Name',password($Password),'$CPassword','$EMail','$Website','$Location','$Occupation','$ICQ','$MSN','$AIM','$Yahoo')";
$result = @mysql_query($sql) or die("Couldn't execute query.".mysql_error());

mysql_close($connection);
?>

I didn't test it, but it should work. Just create a table that "websitetest" can access and replace "your_table_name" above with it. It should work with the rest of Register.php

Link to comment
https://www.neowin.net/forum/topic/147200-help-parse-error/#findComment-1874323
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Don’t care about a wrestling union. No normal person should care. 
    • Limassol, Cyprus. Just south of Turkey. NOT Russia.
    • Hello, Given the reports of Chinese Mini PCs shipping with malware, I would recommend wiping the machine and performing a clean install of Windows on it before use.  From what I can infer from the reports, the Mini PCs that shipped with malware were not the result of targeted purposeful action on the part of the device manufacturers (which is something that has happened with low-cost Android smartphones and TV boxes from China) but rather due to lax security in the manufacturing process.   Getting back to the subject at hand, there are a few steps you will want to go through before wiping the Mini PC: You can start preparing even before the Mini PC arrives.  Once you have ordered it and know the brand and model, go to the manufacturer's website and download all of the latest device drivers, BIOS (UEFI) firmware updates, machine-specific software (if any), and manuals.  Many Mini PC manufacturers do not do a lot of customization of their device drivers, just shipping whatever device drivers the the silicon vendors provide.  I still recommend downloading them, though, just in case there are some customizations or for initial install since those are the drivers you know the manufacturer validated for the Mini PC.  Store these in a safe place, so you have them ready when the Mini PC arrives. Use Microsoft's Windows Media Creation Tool to create an installation USB.  You can also create a directory on installation USB--like C:\DRIVERS\ or whatnot--and store the extracted device drivers there in case you need them while or after installing Windows. Once the Mini PC arrives, and you have your Windows installation USB available, you can proceed with wiping the PC and doing the clean install.  Here's how you do that, step-by-step: Check the computer and make sure you know how to boot it from a USB flash drive (may be a specific key you have to press when the computer is powered on, or a change to the BIOS (UEFI) firmware settings.  The PC may tell you what key combination you need to press to boot from another drive, or the manual for the PC may it. Plug the USB flash drive into the computer and power it up using the means to have it boot from the Windows install USB. Once the computer finishes booting, it should be at a Windows installation screen. Do not agree to any prompts, copyright licenses, or click on any buttons. Press the Shift + F10 keys together to open a Command Prompt. Run DISKPART to start the command-line disk partitioning utility. The command line prompt will change to DISKPART>. At the DISKPART> prompt, type LIST DISK to get the numbers of all drives installed in the system. Make a note of what number is assigned to what drive (if the Mini PC has more than one drive).  At the DISKPART> prompt, type SEL DISK n  where n is the number of the drive containing Windows. At the DISKPART> prompt, type CLEAN and this will erase the GPT/MBR code from the beginning of the drive. *WARNING:* After performing the clean operation, the drive now be blank/erased, and everything on it will be gone (all files, etc.).  You can exit DiskPart and just continue with the Windows installation as you normally would.  If needed, you can install the device drivers you put on the Windows install media to get your network connection up and running, and from there run Windows Update to get the operating system and device drivers up to date Regards, Aryeh Goretsky
    • Why? Amazon has some great shows and Fallout was near perfect.
  • Recent Achievements

    • Week One Done
      cac1lll earned a badge
      Week One Done
    • One Month Later
      Falcon.ai earned a badge
      One Month Later
    • Week One Done
      Falcon.ai earned a badge
      Week One Done
    • Dedicated
      EYEREX earned a badge
      Dedicated
    • First Post
      Electronic Person earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      628
    2. 2
      ATLien_0
      238
    3. 3
      Xenon
      166
    4. 4
      neufuse
      142
    5. 5
      +FloatingFatMan
      123
  • Tell a friend

    Love Neowin? Tell a friend!