Page 1 of 1
Just moved to a new domain and I have a problem.
Posted: Mon Jan 31, 2005 3:22 pm
by Wldrumstcs
Wherever I have PHP in my page, it comes up with this warning:
"Notice: Use of undefined constant username - assumed 'username' in C:\Accounts\wwshssoc\wwwRoot\index.php on line whatever"
How the heck do I fix that?
Posted: Mon Jan 31, 2005 3:33 pm
by josh
Posted: Mon Jan 31, 2005 3:36 pm
by John Cartwright
jshpro2 wrote:On the first line:
The last thing you want to do is hide your problems.
Why not fix them...
The last time I saw that error message is when I forgot the $ for a variable name.
Posted: Mon Jan 31, 2005 3:37 pm
by Wldrumstcs
I don't think I made it clear. All these pages work fine (I know because I had them on a previous site and just transferred them to the new domain). I changed the links and set up the databases, but thats it. The pages show up, but have all these little errors on them wherever there is PHP in the script.
Posted: Mon Jan 31, 2005 3:40 pm
by John Cartwright
Just because they "work" doesn't mean they "work" if you know what I mean.. post some code.
Posted: Mon Jan 31, 2005 3:41 pm
by Wldrumstcs
Code: Select all
<tr>
<td width="100%" colspan="3" height="22" bgcolor="#FF7800">
<p align="center"><font size="4"> Main | <a href="homework.php">Homework</a> | <a href="links.php">Links</a> | </font> <a href="teachers.php">
<font size="4">Teachers</a> | <a href="tests.php">Tests</a><? IF($_COOKIEїusername] == "" OR $_COOKIEїpassword] == ""){ echo "";}ELSEIF($_COOKIEїusername] != "" AND $_COOKIEїpassword] != "" AND $_GETїa] != "logout"){ echo " | <a href='admin.php'>Admin</a>";} ?>
</font></td>
</tr>
The strange thing is is that I am using the same host on both sites, but it doesn't 100% work on the new domain.
Posted: Mon Jan 31, 2005 3:43 pm
by John Cartwright
you have to change the array indices to quotes
for example
$_COOKIE["name"] instead of $_COOKIE[name]
hope you get the point
as jshpro2 somewhat pointed out, your level of error reporting on the hosts is different
Posted: Mon Jan 31, 2005 3:45 pm
by Wldrumstcs
Ugh. Why did it work before without the quotes?
Posted: Mon Jan 31, 2005 3:48 pm
by John Cartwright
I already answered that. What is the big problem on adding quotes.
Posted: Mon Jan 31, 2005 4:03 pm
by Wldrumstcs
Sorry, I hadn't seen your post when I asked that. Anywho, the quotes are annoying cuz I gotta go thru each page and change them. I can't just do "Replace All" because some things are already in quotes. What is wrong with this below script. It says unexpected 'T_STRING' or 'T_variable'.
Code: Select all
<? IF($_COOKIEї'username'] == "" OR $_COOKIEї'password'] == ""){ echo "You are not logged in. <a href='http://www.***.com/login.php'>Click here to login.</a>";}ELSEIF($_COOKIEї'username'] != "" AND $_COOKIEї'password'] != ""){ echo "Welcome $_COOKIEї'username']. <a href='logout.php'>Click here to logout.</a>";} ?>
Posted: Mon Jan 31, 2005 5:50 pm
by feyd
php is getting confused as to what you are intending to do. When placing variables inside a double quoted string, it is recommended that you add braces around the variable so php knows how to add the information needed. Although making all strings single quote strings, and using concatenation to add variables to them is recommended more often.