Just moved to a new domain and I have a problem.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

Just moved to a new domain and I have a problem.

Post 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?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

On the first line:

Code: Select all

error_reporting(E_NONE);
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

jshpro2 wrote:On the first line:

Code: Select all

error_reporting(E_NONE);
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.
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

Post 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.
Last edited by Wldrumstcs on Mon Jan 31, 2005 3:40 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Just because they "work" doesn't mean they "work" if you know what I mean.. post some code.
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

Post 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&#1111;username] == "" OR $_COOKIE&#1111;password] == "")&#123; echo "";&#125;ELSEIF($_COOKIE&#1111;username] != "" AND $_COOKIE&#1111;password] != "" AND $_GET&#1111;a] != "logout")&#123; echo " | <a href='admin.php'>Admin</a>";&#125; ?>
		

		</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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

Post by Wldrumstcs »

Ugh. Why did it work before without the quotes?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I already answered that. What is the big problem on adding quotes.
Wldrumstcs
Forum Commoner
Posts: 98
Joined: Wed Nov 26, 2003 8:41 pm

Post 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&#1111;'username'] == "" OR $_COOKIE&#1111;'password'] == "")&#123; echo "You are not logged in.  <a href='http://www.***.com/login.php'>Click here to login.</a>";&#125;ELSEIF($_COOKIE&#1111;'username'] != "" AND $_COOKIE&#1111;'password'] != "")&#123; echo "Welcome $_COOKIE&#1111;'username'].  <a href='logout.php'>Click here to logout.</a>";&#125; ?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply