Jump to content

Php dreamweaver error


Bounty

Recommended Posts

Heya...i'm getting this strange result when writing php in dreamweaver. When typing <?php tag below <body> it goes red letters and it displays it as an error..even in basic scripts like

 

<html>
<body>

<?php
echo "Hello World";
?>

</body>
</html>

 

This is the picture of it..

91204094.jpg

And when i try to open my html page all html comments (text behind "//") shows on the page..

Can you tell me what is wrong?

Link to comment
Share on other sites

Here...this is the original code it wont work too...://

 

<html>
<body>
<?php
$url = /'http://www.yourdomain.com/accountok.php\'; // Where to redirect 
//the user after that form has been processed successfully. Now we will 
//get the values sent by the form: to get a value you can generally access 
//it with $_POST[\'valuename\'] where valuename is the string you put into 
//the value of the the field you are accessing
$user = $_POST[\'username\'];//get username from form
$pass = $_POST[\'password\'];//get password from form
$pass2 = $_POST[\'password2\'];//get password2 from form
$name = $_POST[\'name\'];//get name from form
$domain = $_POST[\'domain\'];//get domain from form
$zip = $_POST[\'zip\'];//get zip from form
$city = $_POST[\'city\'];//get city from form
$email = $_POST[\'email\'];//get email from form
$state = $_POST[\'state\'];//get state from form
$country = $_POST[\'country\'];//get country from form
$address = $_POST[\'address\'];//get address from form
$phone = $_POST[\'phone\'];//get phone from form

//now that we have picked all the values we need from the form we can 
//start checking them one at a time

//PASSWORD VERIFICATION
if (($pass)!=($pass2)) //if the values stored in the 2 variables are 
//different we redirect the users to a previously created error page
{
header("Location: error-pwverify.php"); //the user will be sent to this page
Die();
}
//EMAIL VERIFICATION
function CheckMail($email) // this function checks if the email format is ok, 
//if the chars are allowed, if there are enough chars in the TLD learn more 
//about eregi function here: http://www.php.net/manual/en/function.eregi.php
{
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$",$email)) 
{ 
	return true;
}
else 
{ 
	return false; 
}
}
if ((empty($email)) || (!CheckMail($email))) //here we check if the email is 
//empty and if the previous function controls are passed, if there are 
//errors the user is sent to a previously prepared custom error page
{
header("Location: error-email.php"); //the user will be sent to this page
Die();
}
//ZIP CODE VERIFICATION
function CheckZip($zip) 
{
if (eregi("[0-9]", $zip)) //here we check if the ZIP code contains only numbers
{
	return true;
}
else 
{ 
	return false; 
}
}
if ((empty($zip)) || (!CheckZip($zip)) || (strlen($zip)!=5))
//if the ZIP code is empty, the CheckZip function fails or the code length is 
//different from 5 chars the user is sent to a previously prepared custom error page
{
header("Location: error-zip.php"); //the user will be sent to this page
Die();
}
//NAME VERIFICATION
//the name and the following fields don\'t allow us to make strict 
//verifications by the way the user has to have a name so if the name 
//is empty the user is sent to a previously prepared custom error page
if (empty($name))
{
header("Location: error-name.php"); //the user will be sent to this page
Die();
}
//CITY VERIFICATION
//exactly the same as the name verification
if (empty($city))
{
header("Location: error-city.php"); //the user will be sent to this page
Die();
}
//STATE/PROVINCE VERIFICATION
//exactly the same as the name verification
if (empty($state))
{
header("Location: error-state.php"); //the user will be sent to this page
Die();
}
//COUNTRY VERIFICATION
//exactly the same as the name verification
if (empty($country))
{
header("Location: error-country.php"); //the user will be sent to this page
Die();
}
//ADDRESS VERIFICATION
//exactly the same as the name verification
if (empty($address))
{
header("Location: error-address.php"); //the user will be sent to this page
Die();
}
//USER AND PASSWORD LENGTH CHECK
$min_lenngth = 6; //this value is the minimal length that we desire our passwords 
//to be if the username or the password is shorter than 6 chars the user is sent 
//to a previously prepared custom error page
if(strlen($user) < $min_lenngth || strlen($pass) < $min_lenngth)
{
header("Location: error-pwshort.php"); //the user will be sent to this page
Die();
}
//NOTE: insert here the code between //****************// and //****************// 
//in the following part of the tutorial if you want to add these values to your 
//database
//NOTE:don\'t use the following code line (erase it) if you inserted here the code 
//to add the values to the database
//if all our checks are passed we go to the url assigned at the top to the variable url
echo <META HTTP-EQUIV=Refresh CONTENT="0; URL=.$url.">;
?>
</body>
</html>

Link to comment
Share on other sites

On this line....

 

$url = /'http://www.yourdomain.com/accountok.php\'; // Where to redirect 

 

The very first / does not belong there. Your also escaping the closing '

 

Then, all these lines....

 

$user = $_POST[\'username\'];//get username from form

 

Why are you escaping the single quotes? Don't.

 

Generally, if your editor starts highlighting things incorrectly it means your code is incorrect. As is the case here.

Link to comment
Share on other sites

Its solved for now...if i have any more difficulties with this ill post them here..thanks for quick answer :))

 

Another question...

 

Can you tell me how can i make a page that creates pages...like on youtube.com,every clip has its own page,right? and only 1 page that makes them (the upload one)...or can you at least point me in right direction...a tutorial or anything...

 

Thanks =)))

Link to comment
Share on other sites

This is pretty much the basics of what php is used for. Creating dynamic pages from data stored within a database. You don't actually create a physical page for each clip.

 

There's some sort of example I wrote here : http://www.phpfreaks.com/forums/index.php/topic,227131.msg1048650.html#msg1048650

 

Though the net would have literally thousands of examples of this if your searched.

Link to comment
Share on other sites

I would search if i knew what i was looking for or how to name it xDD

Thanks on answers i will try all of this today so if i get any errors ill post here ;)

 

Umm i just remembered one...where can i find virtual ftp server,like offline host so i can test all of this...?

Link to comment
Share on other sites

where can i find virtual ftp server,like offline host so i can test all of this...?

 

You need a http server and your much better off installing one locally. Google for Xampp to get up and running easily.

Link to comment
Share on other sites

Ok i installed the software and it works charming...only problem is in my script line 166 witch says:

echo <META HTTP-EQUIV=Refresh CONTENT="0; URL=.$url.">

Error:

syntax error, unexpected '<' in C:\xampp\htdocs\livereg.php on line 166

Whats the problem?

Link to comment
Share on other sites

One more..

$connection = mysql_connect('host', 'user', 'password');

I'm using this Xampp virtual server program...ive never registered or anything...what is my db password and how can i change it???

Link to comment
Share on other sites

Ok i managed to change the password and now it connects ok...but it wont select sql database,this is the code..idk what is wrong :///

 

$connection = mysql_connect("localhost", "root", "*password*");
mysql_select_db("users") or die( "Unable to select database");

 

Database is called "users"...:/

 

Thanks u helped me alot :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.