Hi,

I got the syntax error in my following php code:
unexpected T_STRING in /net/home/z6zhou/public_html/signup.php on line 1. Who can help it out?

my php code is as follows:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head><title>Publication DB</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Language" content="en-us" />
<link rel="stylesheet" href="style.css" type="text/css" />

<link href="/stylesheets/snippets.css?1239220407" media="screen" rel="Stylesheet" type="text/css" />
<link href="/stylesheets/minitabs.css?1229957682" media="screen" rel="Stylesheet" type="text/css" />


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

<script type="text/javascript">
_uacct = "UA-2557640-1";
urchinTracker();
</script>

</head>


//<body bgcolor =" 000000" TEXT="cccccc" LINK =" ff99ff" VLINK =" ff8888" ALINK =" 884488">

<body background ="ice-light.jpg" TEXT="black">



// create an acount code starting 

<div id="container">

<script type="text/javascript">
//<![CDATA[
function validate_login(frm) {
  var value = '';
  var errFlag = new Array();
  var _qfGroups = {};
  _qfMsg = '';

  value = frm.elements['username'].value;
  if (value == '' && !errFlag['username']) {
    errFlag['username'] = true;
    _qfMsg = _qfMsg + '\n - login cannot be empty';
  }

  value = frm.elements['password'].value;
  if (value == '' && !errFlag['password']) {
    errFlag['password'] = true;
    _qfMsg = _qfMsg + '\n - password cannot be empty';
  }

  value = frm.elements['email'].value;
  var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((2
5[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9
]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Z
a-z\-]+))$/;
  if (value != '' && !regex.test(value) && !errFlag['email']) {
    errFlag['email'] = true;
    _qfMsg = _qfMsg + '\n - invalid email address';
  }

  if (_qfMsg != '') {
    _qfMsg = 'Invalid information entered.' + _qfMsg;
    _qfMsg = _qfMsg + '\nPlease correct these fields.';
    alert(_qfMsg);
    return false;
  }
  return true;
}
// ]]>
</script>

<form id="su_form" method="POST" action="/~z6zhou/signup.php" name="login" onsubmit="try { var myValidator = validate_login; } catch(e) { return true; } return myValidator(this);
">
<p><label for="login" class="signup">Desired Username</label><br/>
<input id="user_username" name="user[username]" size="30" type="text" /></p>

<p><label for="email" class="signup">Email</label><br/>

<input id="user_email" name="user[email]" size="30" type="text" onkeypress="su_check_email();" /></p>

<p><label for="email" class="signup">Real name</label><br/>
<input id="user_realname" name="user[realname]" size="30" type="text" /></p>

<p><label for="email" class="signup">Your URL <em>(optional)</em></label><br/>
<input id="user_url" name="user[url]" size="30" type="text" /></p>

<p><label for="password" class="signup">Password</label><br/>
<input id="user_plainpassword" name="user[plainpassword]" size="30" type="password" onkeypress="su_check_passwd();" onblur="su_check_passwd();" /></p>

<p><label for="password" class="signup">Confirm Password</label><br/>

<input id="user_plainpassword_confirmation" name="user[plainpassword_confirmation]" size="30" type="password" onkeypress="su_check_passwd();" onblur="su_check_passwd();" /></p>

<p><input name="commit" type="submit" value="Sign up" /></p>
<p><input name="redirect" type="hidden" value="/~z6zhou/signup.php" /></p>
</form>

<br style="clear: both" />

<div id="footer">
        <p>Copyright &copy; 2009 <a href=" ">    </a></p>

   // Site Meter 
        <p><a href="   "><img src="sea.jpg" width="120" height="30" border="0" alt=""/></a></p>

</div>

</div>
<script src="/javascripts/prototype.js?1229957682" type="text/javascript"></script>
<script src="/javascripts/effects.js?1229957682" type="text/javascript"></script>

<script src="/javascripts/dragdrop.js?1229957682" type="text/javascript"></script>
<script src="/javascripts/controls.js?1229957682" type="text/javascript"></script>
<script src="/javascripts/general.js?1229957682" type="text/javascript"></script>

//  end of creating an acount code

</body>
</html>
somedude3488 commented: Use [code] tags. -1

Use code tags. It really hard to follow your code.

There is 0 php in the code you posted. The only reason you are getting the error is because you have short_tags enabled.

<?xml version="1.0" encoding="utf-8"?>

causes an error because <? is the opening (short) tag for php.
Replace it with:

<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>

The error is solved. Thanks. My php code is to create an online account for signing up in my homepage. But it doesn't work. Could you tell me the reasons?

You need to post the code.

My following php code is to create an online account for signing up in my homepage. But it doesn't work. Could you tell me the reasons?

---
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head><title>Publication DB</title><meta http-equiv="Content-Type" content="text
/html; charset=utf-8" /><meta http-equiv="Content-Language" content="en-us" />
<link rel="stylesheet" href="style.css" type="text/css" />

<link href="/stylesheets/snippets.css?1239220407" media="screen" rel="Stylesheet
" type="text/css" />
<link href="/stylesheets/minitabs.css?1229957682" media="screen" rel="Stylesheet
" type="text/css" />


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

<script type="text/javascript">
_uacct = "UA-2557640-1";
urchinTracker();
</script>

</head>



<body background ="ice-light.jpg" TEXT="black">




<div id="container">

<script type="text/javascript">
//<![CDATA[
function validate_login(frm) {
  var value = '';
  var errFlag = new Array();
  var _qfGroups = {};
  _qfMsg = '';

  value = frm.elements['username'].value;
  if (value == '' && !errFlag['username']) {
    errFlag['username'] = true;
    _qfMsg = _qfMsg + '\n - login cannot be empty';
  }

  value = frm.elements['password'].value;
  if (value == '' && !errFlag['password']) {
    errFlag['password'] = true;
    _qfMsg = _qfMsg + '\n - password cannot be empty';
  }

  value = frm.elements['email'].value;
  var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(
\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?
[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4]
[0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(
((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[
0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][
0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;
  if (value != '' && !regex.test(value) && !errFlag['email']) {
    errFlag['email'] = true;
    _qfMsg = _qfMsg + '\n - invalid email address';
  }

  if (_qfMsg != '') {
    _qfMsg = 'Invalid information entered.' + _qfMsg;
    _qfMsg = _qfMsg + '\nPlease correct these fields.';
    alert(_qfMsg);
    return false;
  }
  return true;
}
// ]]>
</script>

<form id="su_form" method="POST" action="/~z6zhou/signup.php" name="login" onsub
mit="try { var myValidator = validate_login; } catch(e) { return true; } return 
myValidator(this);">
<p><label for="login" class="signup">Desired Username</label><br/>
<input id="user_username" name="user[username]" size="30" type="text" /></p>

<p><label for="email" class="signup">Email</label><br/>

<input id="user_email" name="user[email]" size="30" type="text" onkeypress="su_c
heck_email();" /></p>

<p><label for="email" class="signup">Real name</label><br/>
<input id="user_realname" name="user[realname]" size="30" type="text" /></p>

<p><label for="email" class="signup">Your URL <em>(optional)</em></label><br/>
<input id="user_url" name="user[url]" size="30" type="text" /></p>

<p><label for="password" class="signup">Password</label><br/>
<input id="user_plainpassword" name="user[plainpassword]" size="30" type="passwo
rd" onkeypress="su_check_passwd();" onblur="su_check_passwd();" /></p>

<p><label for="password" class="signup">Confirm Password</label><br/>

<input id="user_plainpassword_confirmation" name="user[plainpassword_confirmatio
n]" size="30" type="password" onkeypress="su_check_passwd();" onblur="su_check_p
asswd();" /></p>

<p><input name="commit" type="submit" value="Sign up" /></p>
<p><input name="redirect" type="hidden" value="/~z6zhou/signup.php" /></p>
</form>

<br style="clear: both" />

<div id="footer">
        <p>Copyright &copy; 2009 <a href=" ">    </a></p>

        <p><a href="   "><img src="sea.jpg" width="120" height="30" border="0" a
lt=""/></a></p>

</div>

</div>
<script src="/javascripts/prototype.js?1229957682" type="text/javascript"></scri
pt>
<script src="/javascripts/effects.js?1229957682" type="text/javascript"></script
>

<script src="/javascripts/dragdrop.js?1229957682" type="text/javascript"></scrip
t>
<script src="/javascripts/controls.js?1229957682" type="text/javascript"></scrip
t>
<script src="/javascripts/general.js?1229957682" type="text/javascript"></script
>

</body>
</html>

Thats not php. Its html and javascript.

But it doesn't work. Could you tell me the reasons?

Hey.

Sadly, the fact that the code doesn't work doesn't exactly help us debug it. Nor does posting the part of your PHP code that isn't actually PHP ;-)

Please explain why/how it isn't working, what you have tried to fix it, and why it failed. And, of course, any and all error messages you get.

We aren't here to debug the code for you. We are here to help you debug it.

Could you tell me how to change my following html code into php code?
Thanks.

----
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<head><title>Publication DB</title><meta http-equiv="Content-Type" content="text
/html; charset=utf-8" /><meta http-equiv="Content-Language" content="en-us" />
<link rel="stylesheet" href="style.css" type="text/css" />

<link href="/stylesheets/snippets.css?1239220407" media="screen" rel="Stylesheet
" type="text/css" />
<link href="/stylesheets/minitabs.css?1229957682" media="screen" rel="Stylesheet
" type="text/css" />


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

<script type="text/javascript">
_uacct = "UA-2557640-1";
urchinTracker();
</script>

</head>



<body background ="ice-light.jpg" TEXT="black">




<div id="container">

<script type="text/javascript">
//<![CDATA[
function validate_login(frm) {
  var value = '';
  var errFlag = new Array();
  var _qfGroups = {};
  _qfMsg = '';

  value = frm.elements['username'].value;
  if (value == '' && !errFlag['username']) {
    errFlag['username'] = true;
    _qfMsg = _qfMsg + '\n - login cannot be empty';
  }

  value = frm.elements['password'].value;
  if (value == '' && !errFlag['password']) {
    errFlag['password'] = true;
    _qfMsg = _qfMsg + '\n - password cannot be empty';
  }

  value = frm.elements['email'].value;
  var regex = /^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+(
\.[\w\!\#\$\%\&'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?
[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4]
[0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(
((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[
0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][
0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/;
  if (value != '' && !regex.test(value) && !errFlag['email']) {
    errFlag['email'] = true;
    _qfMsg = _qfMsg + '\n - invalid email address';
  }

  if (_qfMsg != '') {
    _qfMsg = 'Invalid information entered.' + _qfMsg;
    _qfMsg = _qfMsg + '\nPlease correct these fields.';
    alert(_qfMsg);
    return false;
  }
  return true;
}
// ]]>
</script>

<form id="su_form" method="POST" action="/~z6zhou/signup.php" name="login" onsub
mit="try { var myValidator = validate_login; } catch(e) { return true; } return 
myValidator(this);">
<p><label for="login" class="signup">Desired Username</label><br/>
<input id="user_username" name="user[username]" size="30" type="text" /></p>

<p><label for="email" class="signup">Email</label><br/>

<input id="user_email" name="user[email]" size="30" type="text" onkeypress="su_c
heck_email();" /></p>

<p><label for="email" class="signup">Real name</label><br/>
<input id="user_realname" name="user[realname]" size="30" type="text" /></p>

<p><label for="email" class="signup">Your URL <em>(optional)</em></label><br/>
<input id="user_url" name="user[url]" size="30" type="text" /></p>

<p><label for="password" class="signup">Password</label><br/>
<input id="user_plainpassword" name="user[plainpassword]" size="30" type="passwo
rd" onkeypress="su_check_passwd();" onblur="su_check_passwd();" /></p>

<p><label for="password" class="signup">Confirm Password</label><br/>

<input id="user_plainpassword_confirmation" name="user[plainpassword_confirmatio
n]" size="30" type="password" onkeypress="su_check_passwd();" onblur="su_check_p
asswd();" /></p>

<p><input name="commit" type="submit" value="Sign up" /></p>
<p><input name="redirect" type="hidden" value="/~z6zhou/signup.php" /></p>
</form>

<br style="clear: both" />

<div id="footer">
        <p>Copyright &copy; 2009 <a href=" ">    </a></p>

        <p><a href="   "><img src="sea.jpg" width="120" height="30" border="0" a
lt=""/></a></p>

</div>

</div>
<script src="/javascripts/prototype.js?1229957682" type="text/javascript"></scri
pt>
<script src="/javascripts/effects.js?1229957682" type="text/javascript"></script
>

<script src="/javascripts/dragdrop.js?1229957682" type="text/javascript"></scrip
t>
<script src="/javascripts/controls.js?1229957682" type="text/javascript"></scrip
t>
<script src="/javascripts/general.js?1229957682" type="text/javascript"></script
>


</body>
</html>

I tried to create an online account for signing up in my homepage by php code. But my code seems html and not php. My question is how to change my html code into php and make my online sign up account work. My homepage is
http://www.bioinformatics.uwaterloo.ca/~z6zhou/signup.php
Please take a look at the source code and tell me why it doesn't work. Thanks a lot.

Search online for registration scripts, there are lots of them.

We will not write your code for you, go research it and ask specific questions when something doesn't work.

Use code tags, its easy. Highlight the code and click the Code button...

Also, why the hell do you have a >2MB jpg image on the page? Waste of bandwidth there.

Could you give me some hints? I got troubles in researching it myself.

To create the registration account in my homepage, do I need to set up a database to store all usernames and passwords? If I do, how to set up the database on the unix server where my homepage is on?

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.