Click to See Complete Forum and Search --> : Parse error: syntax error, unexpected T_VARIABLE


scourtwright
03-18-2005, 01:01 PM
hi everyone,

I'm getting this error message from my script
"Parse error: syntax error, unexpected T_VARIABLE in C:\Program Files\Apache Group\Apache2\htdocs\sel_byid.php on line 18".
I have no Idea what this is or more importantly what it is trying to tell me to fix. I just started working with PHP, MYSQL, and APACHE. Here is my script, and thank you for your help.

<?
$db_name = "testdb2";
$table_name = "my_music";

$connection = @mysql_connect("localhost", "xxxxx", "xxxxx")
or die(mysql_error());

$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$sql = "SELECT * FROM $table_name ORDER BY id";

$result = @mysql_query($sql,$connection) or die(mysql_error());

while ($row = mysql_fetch_array($result)) {

$id = $row['id'];
$format = $row['format']
$title = stripslashes($row['title']);
$artist_fn = stripslashes($row['artist_fn']);
$artist_ln = stripslashes($row['artist_ln']);
$rec_label = stripslashes($row['rec_label']);
$my_notes = stripslashes($row['my_notes']);
$date_acq = $row['date_acq'];

if (artist_fn != "") {
$artist_fullname = trim("$artist_fn $artist_ln");
} else {
$artist_fullname = trim("artist_ln");
}

if ($date_acq == "0000-00-00") {
$date_acq = "[unknown]";
}

$display_block .= "<P><strong>$title</strong> on $rec_label,
by $artist_fullname<br>
$my_notes <em>(acquired:$date_acq, format:$format)</em></P>";
}
?>

<HTML>
<HEAD>
<TITLE>My Music (Ordered by ID)</TITLE>
</HEAD>
<BODY>
<H1>My Music: Ordered By ID</H1>
<? echo "$display_block"; ?>
<P><a href="my_menu.html">Return to menu</a></P>
</BODY>
</HTML>

laserlight
03-18-2005, 01:05 PM
$format = $row['format']
is missing the terminating semi-colon.

Basically, look at line 18, and the surrounding code if necessary, to determine the problem.

Djibri
04-05-2007, 03:55 PM
I have similar problem. I see the message: "Parse error: syntax error, unexpected T_VARIABLE in ......\moviedata.php on line 16" when I open my file and I can't understend where is my mistake. Here is my code:

<?php
//connect to MySQL
$connect = mysql_connect("localhost", "xxx", "xxx") or die ("Proveri si vryzkata sys server-a.");

//uverqvame se 4e polzame pravilnata DB
mysql_select_db("moviesite");

//vyvejdane da danni v tablicata "movie"
$insert = "INSERT INTO movie (movie_id, movie_name, movie_type, movie_year, movie_leadactor, movie_director) " .
"VALUES (1, 'Bruce Almighty', 5, 2003, 1, 2), " .
"(2, 'Office Space', 5, 1999, 5, 6), " .
"(3, 'Grand Canyon', 2, 1991, 4, 3)";
$results = mysql_query($insert)

//vyvejdane na danni v tablicata "movietype"
$type = "INSERT INTO movietype (movietype_id, movietype_label) " .
"VALUES (1, 'Sci Fi'), " .
"(2, 'Drama'), " .
"(3, 'Adventure'), " .
"(4, 'War'), " .
"(5, 'Comedy'), " .
"(6, 'Horror'), " .
"(7, 'Action'), " .
"(8, 'Kids')" ;
$resuts = mysql_query($type) or die (mysql_error());

//vyvejdane na danni v tablicata "people"
$people = "INSERT INTO people (people_id, people_fullname, people_isactor, people_isdirector) " .
"VALUES (1, 'Jim Carrey', 1, 0), " .
"(2, 'Tom Shadyac', 0, 1), " .
"(3, 'Lawrence Kasdan', 0, 1), " .
"(4, 'Kevin Kline', 1, 0), " .
"(5, 'Ron Livingston', 1, 0), " .
"(6, 'Mike Judje', 0, 1)";
$results = mysql_query($people) or die (mysql_error());

echo "Data inserted successfully!";
?>

laserlight
04-05-2007, 03:59 PM
Djibri, you are missing a terminating semi-colon on line 13:
$results = mysql_query($insert)
Next time kindly start your own thread instead of resurrecting an old thread, especially one that is not yours. Link to the old thread if you must.

bradgrafelman
04-06-2007, 01:03 AM
Also, when posting PHP code, please use the board's bbcode tags - they make the code much, much easier to read (as well as aiding the diagnosis of syntax errors). You should edit your post now and add these bbcode tags to help others in reading/analyzing your code.

jmbrink26
08-15-2008, 12:03 AM
Hi All,

This is racking my brain. I am getting the all infamous "Parse error: syntax error, unexpected T_VARIABLE" message. I know that 9 times out of 10 your either missing a semi-colon or opening/closing brackets in statements. I have checked my code like 20 times and I am just not seeing it! :P

Maybe you guys could see it.

I am trying to take this "test" I guess you can call it for this freelance php developer gig, and want to make sure all the code works before I send it back to them for review.

Exact error is: "
Parse error: syntax error, unexpected T_VARIABLE in /home/content/j/m/b/jmbrink26/html/testing/index.php on line 39"

Here is the code:

<?php

//Database Connection
$msdb = mysql_connect("xxx", "xxx", "xxx");
mysql_select_db("test", $msdb) or die(mysql_error());

/*
GENERAL INFORMATION:
Below is the current table structure for 'members':
=====
ID: id (autoincrement)
firstname
lastname
phonenumber
=====

PUT YOUR NAME HERE PLEASE: John Doe

PART 1:
-------
* Below, write the PHP code to insert a first name, last name, and phone number
into the 'members' table. Use an HTML form to collect this information, then store it to the 'members' table.
//
*/


/*
PART 2:
-------
* Below, write the PHP code to retrieve the previously inserted record from the
'tests' table and display it in the browser.
//*/

// PHP Code
// Code to pass HTML POST data

$firstName = $_POST['firstname'];
$lastName = $_POST['lastname'];
$phoneNumber = $_POST['phonenumber']; //This is line 39 in my IDE
if(!$firstName || !$lastName || !$phoneNumber) {
echo "You did not enter all the necessary data into the fields as requested. Please fill in the information below and try again. Thank you.";
} else {
$number = is_numeric($phoneNumber);
if($number == false) {
echo "You did not type the Phone Number in the format shown as example in the field. Please fill in the information below and try again. Thank you.";
} else {
$insert = "INSERT INTO members (firstname, lastname, phonenumber) VALUES($firstName, $lastName, $phoneNumber);";
mysql_query($insert);
//Code to retrieve record just inserted
$query = "SELECT * FROM members WHERE firstname = $firstName AND lastname = $lastName AND phonenumber = $phoneNumber;";
$result = mysql_query($query);
echo $result;
}
?>

<html>

<head>

<title>PHP TEST</title>
<!-- Link to a fake CSS Stylesheet -->
<link rel="stylesheet" href="test.css" />
</head>

<body>

<h2>PHP TEST</h2>
<br />
<p>Please enter data into all the fields, or an error will display. Thank you for your cooperation.</p>
<br />
<table name="form_table" id="form_table">
<form name="phptest_form" id="phptest_form" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<tr>
<td>First Name &nbsp;</td>
<td><input type="text" name="firstname" id="firstname" /></td>
</tr>
<tr>
<td>Last Name &nbsp;</td>
<td><input type="text" name="lastname" id="lastname" /></td>
</tr>
<tr>
<td>Phone Number &nbsp;</td>
<td><input type="text" name="phonenumber" id="phonenumber" value="0000000000" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</form>
</table>
</body>
</html>

Thanks in advance for your help.

bradgrafelman
08-15-2008, 02:40 AM
Is that the entire script? I get a different parse error: Parse error: syntax error, unexpected $end in C:\php\test.php on line 92.

That parse error is referring to the unclosed '}' on the first else statement.

Krik
08-15-2008, 02:46 AM
Next time kindly start your own thread instead of resurrecting an old thread, especially one that is not yours. Link to the old thread if you must.

Next time maybe a bit of reading would be in order (2 posts above yours)

But the solution is maybe a bit easier than you think.

I have had comment lines throw off the error reporting, as far as the line with the error goes. Count the number of commented lines and add that to the 39 and see if you find the problem. If there are more commented lines in the code as you add you may need to add one more line for each. This will get you closer to the correct line of the error.

bradgrafelman
08-15-2008, 02:50 AM
Also, jmbrink26, this bit of code: <?php $_SERVER['PHP_SELF']; ?>does nothing. Perhaps you meant: <?php echo $_SERVER['PHP_SELF']; ?>?

jmbrink26
08-15-2008, 03:06 AM
Yes, that's it.

Interestingly enough though, I copied all the text from the original file, and pasted it into a new file, and then I got that same error about the $end. I forgot 1 curley brace at the end, and that fixed that issue.

Thanks for the reminder to put the echo in the php_self line, I totally forgot about that. Been a while since I've passed variables that way... That would explain why nothing ever gets inserted into the mysql table :P

Thanks again. Much appreciated! :)

hosseind600
10-22-2008, 12:18 PM
hi every body
i have a problem with this code:
////////////////////////////
// config.php //
////////////////////////////


////////////////////////////////////// CONNECTIN TO DATABASE AND SELECTING IT
<?php

$host = $_POST['haddress'];
$usser = $_POST['huser'];
$pass = $_POST['hpass'];
$db = $_POST['hname'];
$connect = mysql_connect($host,$usser,$pass) or die('tghrg');
mysql_select_db($connection,$db) or die('gggg');

//////////////////////////////////// CREATING TABLES AND INSERTING MAIN DATA INTO THEM
//////////dedws
$createinfo = "create table pscms_maininfo (
title char(200) not null default 'Simple cms by parsscript',
sdir char(255) ,
author char(255) not null default 'parsscript.ir',
about text
)";

sql_query($createinfo) or die('g')

//////////////// sending grabed data into pscms_maininfo table

$title = ($_POST['title']);
$sdir = $_post['sdir'];
$author = $_post['author'];
$about = $_post['about'];

$sinfo = "insert into pscms_maininfo (title,sdir,author,about)
values ('$title','$sdir','$author','$about')";
mysql_query($sinfo) or die ('اطلاعات بصورت صحیح ارسال نشدند')

//////////////// creating table pscms_admin

$adminc = "create table pscms_admin (
username char(200) not null default 'admin',
password char(200) not null default 'admin'
)";

mysql_query($adminc) or die ('در ایجاد فضا برای ذخیره اطلاعات مدیریت اشکال وجود دارد ')
//////////////// sending grabed data into pscms_admin table

$username = $_post['auser'];
$password = $_post['apass'];

$sadmin = "insert into pscms_admin (username,password)
values ('$username','$password')";
mysql_query($sadmin) or die ('ارسال اطلاعات مدیریت انجام نشد')

//////////////// creating table pscms_posts

$cposts = "create table pscms_posts (
title char(255),
text text not null default 'بدون محتوی'
)";

mysql_query($cposts) or die ('محلی برای ذخیره مطالب ایجاد نشد')
////////////////


<table border="0" width="50%" align="center">
<tr>
<td bgcolor="#004A18">
<p align="center" dir="rtl">
<font face="Tahoma" size="2" color="#E6FFE6">سیستم با موفقیت نصب گردید<span lang="en-us">!</span></font></td>
</tr>
<tr>
<td bgcolor="#6F4200">
<p dir="rtl"><font face="Tahoma" size="2" color="#FFAB2D">یکی را انتخاب کنید :</font></p>
<p dir="rtl" align="center"><font face="Tahoma" size="2">
<font color="#FFAB2D">&nbsp;</font><a href="index.php"><font color="#FFAB2D">صفحه اصلی وبسایت</font></a><font color="#FFAB2D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<a href="admin/index.php"><font color="#FFAB2D">مرکز کنترل وبسایت
</font> </a>
</font>
</td>
</tr>
</table>


i have a form wich it action is the page contain the this code
when i execute the form i get this error

Parse error: syntax error, unexpected T_VARIABLE in D:\Downloads\xampplite\htdocs\b\config.php on line 29



what should i do??????:confused::confused::glare:

djjjozsi
10-22-2008, 01:00 PM
you must use ; signs at that lines end that must close the commands:

and you forget to close your PHP block
?> was misssing
AND $_POST is with CAPITAL letters!

And, check if you wrote mysql_query command... i found 1 part where you wrote it as wrong..

and use the source code insert in this forum.



<?php

$host = $_POST['haddress'];
$usser = $_POST['huser'];
$pass = $_POST['hpass'];
$db = $_POST['hname'];
$connect = mysql_connect($host,$usser,$pass) or die('tghrg');
mysql_select_db($connection,$db) or die('gggg');

//////////////////////////////////// CREATING TABLES AND INSERTING MAIN DATA INTO THEM
//////////dedws
$createinfo = "create table pscms_maininfo (
title char(200) not null default 'Simple cms by parsscript',
sdir char(255) ,
author char(255) not null default 'parsscript.ir',
about text
)";

mysql_query($createinfo) or die('g');

//////////////// sending grabed data into pscms_maininfo table

$title = $_POST['title'];
$sdir = $_POST['sdir'];
$author = $_POST['author'];
$about = $_POST['about'];

$sinfo = "insert into pscms_maininfo (title,sdir,author,about)
values ('$title','$sdir','$author','$about')";
mysql_query($sinfo) or die ('اطلاعات بصورت صحیح ارسال نشدند');

//////////////// creating table pscms_admin

$adminc = "create table pscms_admin (
username char(200) not null default 'admin',
password char(200) not null default 'admin'
)";

mysql_query($adminc) or die ('در ایجاد فضا برای ذخیره اطلاعات مدیریت اشکال وجود دارد ');
//////////////// sending grabed data into pscms_admin table

$username = $_POST['auser'];
$password = $_POST['apass'];

$sadmin = "insert into pscms_admin (username,password) values ('$username','$password')";
mysql_query($sadmin) or die ('ارسال اطلاعات مدیریت انجام نشد');

//////////////// creating table pscms_posts

$cposts = "create table pscms_posts (
title char(255),
text text not null default 'بدون محتوی'
)";

mysql_query($cposts) or die ('محلی برای ذخیره مطالب ایجاد نشد');

?>

<table border="0" width="50%" align="center">
<tr>
<td bgcolor="#004A18">
<p align="center" dir="rtl">
<font face="Tahoma" size="2" color="#E6FFE6">سیستم با موفقیت نصب گردید<span lang="en-us">!</span></font></td>
</tr>
<tr>
<td bgcolor="#6F4200">
<p dir="rtl"><font face="Tahoma" size="2" color="#FFAB2D">یکی را انتخاب کنید :</font></p>
<p dir="rtl" align="center"><font face="Tahoma" size="2">
<font color="#FFAB2D">&nbsp;</font><a href="index.php"><font color="#FFAB2D">صفحه اصلی وبسایت</font></a><font color="#FFAB2D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<a href="admin/index.php"><font color="#FFAB2D">مرکز کنترل وبسایت
</font> </a>
</font>
</td>
</tr>
</table>

hosseind600
10-22-2008, 01:43 PM
you must use ; signs at that lines end that must close the commands:

and you forget to close your PHP block
?> was misssing
AND $_POST is with CAPITAL letters!

And, check if you wrote mysql_query command... i found 1 part where you wrote it as wrong..

and use the source code insert in this forum.



<?php

$host = $_POST['haddress'];
$usser = $_POST['huser'];
$pass = $_POST['hpass'];
$db = $_POST['hname'];
$connect = mysql_connect($host,$usser,$pass) or die('tghrg');
mysql_select_db($connection,$db) or die('gggg');

//////////////////////////////////// CREATING TABLES AND INSERTING MAIN DATA INTO THEM
//////////dedws
$createinfo = "create table pscms_maininfo (
title char(200) not null default 'Simple cms by parsscript',
sdir char(255) ,
author char(255) not null default 'parsscript.ir',
about text
)";

mysql_query($createinfo) or die('g');

//////////////// sending grabed data into pscms_maininfo table

$title = $_POST['title'];
$sdir = $_POST['sdir'];
$author = $_POST['author'];
$about = $_POST['about'];

$sinfo = "insert into pscms_maininfo (title,sdir,author,about)
values ('$title','$sdir','$author','$about')";
mysql_query($sinfo) or die ('اطلاعات بصورت صحیح ارسال نشدند');

//////////////// creating table pscms_admin

$adminc = "create table pscms_admin (
username char(200) not null default 'admin',
password char(200) not null default 'admin'
)";

mysql_query($adminc) or die ('در ایجاد فضا برای ذخیره اطلاعات مدیریت اشکال وجود دارد ');
//////////////// sending grabed data into pscms_admin table

$username = $_POST['auser'];
$password = $_POST['apass'];

$sadmin = "insert into pscms_admin (username,password) values ('$username','$password')";
mysql_query($sadmin) or die ('ارسال اطلاعات مدیریت انجام نشد');

//////////////// creating table pscms_posts

$cposts = "create table pscms_posts (
title char(255),
text text not null default 'بدون محتوی'
)";

mysql_query($cposts) or die ('محلی برای ذخیره مطالب ایجاد نشد');

?>

<table border="0" width="50%" align="center">
<tr>
<td bgcolor="#004A18">
<p align="center" dir="rtl">
<font face="Tahoma" size="2" color="#E6FFE6">سیستم با موفقیت نصب گردید<span lang="en-us">!</span></font></td>
</tr>
<tr>
<td bgcolor="#6F4200">
<p dir="rtl"><font face="Tahoma" size="2" color="#FFAB2D">یکی را انتخاب کنید :</font></p>
<p dir="rtl" align="center"><font face="Tahoma" size="2">
<font color="#FFAB2D">&nbsp;</font><a href="index.php"><font color="#FFAB2D">صفحه اصلی وبسایت</font></a><font color="#FFAB2D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font>
<a href="admin/index.php"><font color="#FFAB2D">مرکز کنترل وبسایت
</font> </a>
</font>
</td>
</tr>
</table>


thank you for answering
i did what you told and i corrected the misings
but still i have a problem when i execute the form i told you about this error coms

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\Downloads\xampplite\htdocs\b\config.php on line 7
tghrg
now?:confused:

djjjozsi
10-22-2008, 01:59 PM
please answer my question...
if you can
i need your professional guides , please

Lets write the values for the connection:

$host = $_POST['haddress'];
$usser = $_POST['huser'];
$pass = $_POST['hpass'];
$db = $_POST['hname'];

$host = "*******";
$usser ="*******";
$pass = "*******";
$db = "*******";

hosseind600
10-22-2008, 02:08 PM
again thank you

this time this error comes

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in D:\Downloads\xampplite\htdocs\b\config.php on line 8
gggg
do you know why?

djjjozsi
10-22-2008, 02:19 PM
here is a good template to build the connection:

anyway:


in this line was just $connect....
$connection = mysql_connect($host,$usser,$pass) or die('tghrg');
mysql_select_db($connection,$db) or die('gggg');


this is a template 4 you:


<?php

/// For the following details,
/// please contact your server vendor

$hostname='***'; //// specify host, i.e. 'localhost'
$user='****'; //// specify username
$pass='****'; //// specify password
$dbase='****'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?>

hosseind600
10-22-2008, 02:22 PM
answer please

hosseind600
10-22-2008, 03:06 PM
here is a good template to build the connection:

anyway:


in this line was just $connect....
$connection = mysql_connect($host,$usser,$pass) or die('tghrg');
mysql_select_db($connection,$db) or die('gggg');


this is a template 4 you:


<?php

/// For the following details,
/// please contact your server vendor

$hostname='***'; //// specify host, i.e. 'localhost'
$user='****'; //// specify username
$pass='****'; //// specify password
$dbase='****'; //// specify database name
$connection = mysql_connect("$hostname" , "$user" , "$pass")
or die ("Can't connect to MySQL");
$db = mysql_select_db($dbase , $connection) or die ("Can't select database.");
?>


thanks a lot
it works correct:)

djjjozsi
10-22-2008, 03:48 PM
nice!
thanks a lot
it works correct:)

hosseind600
10-22-2008, 06:36 PM
hi again
is there any body that khows how to correct this?

echo "<div dir="rtl">xxx</div>"

arda
06-19-2009, 10:16 AM
hi everybody;

I made a simple update page...but it gave me this error.."Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\new\guncelle.php on line 19"

here is my code..

<?php
$tc_no=$_POST["tc"];
$ad=$_POST["ad"];
$soy=$_POST["soy"];
$ana=$_POST["ana"];
$baba=$_POST["baba"];
$d_yer=$_POST["dyr"];
$d_tar=$_POST["dtrh"];
$medni=$_POST["mdni"];
$is=$_POST["isi"];
$gor=$_POST["gorev"];
$unv=$_POST["unv"];
$trh=$_POST["trh"];
$adr=$_POST["adr"];

$conn=mysql_connect('localhost','root','') or die ('Veritabanina Baglanilamiyor..! Sistem Yöneticisine Basvurunuz.. Hata: ' .mysql_error());
mysql_select_db("db_tutanak",$conn) or die ('Database e Erisilemiyor..Hata : '.mysql_error());

$sql="UPDATE kisisel_bilgi SET adi='"$ad"' , soyadi='"$soy"' , ana_adi='"$ana"' , baba_adi='"$baba"' , d_yer='"$d_yer"' ,d_tar='$"d_tar"' , medeni='"$medni"' , is='"$is"' , gor='"$gor"' , unvan='"$unv"' , tarih='"$trh"' , adres='"$adr"' WHERE tc_no='"$tc_no"'";

$sonuc=mysql_query($sql) or die("Hata : ". mysql_error());

?>

djjjozsi
06-19-2009, 11:46 AM
echo 'echo "<div dir="rtl">xxx</div>"';

or

echo "<div dir=\"rtl\">xxx</div>";

or

?><div dir="rtl">xxx</div><?php
... rest of your code...

djjjozsi
06-19-2009, 11:48 AM
I made a simple update page...but it gave me this error.."Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\new\guncelle.php on line 19"
here is my code..

Remove the double qoute-s from your $SQL script.

$sql="UPDATE kisisel_bilgi SET adi='$ad' ............. WHERE tc_no='$tc_no'";

arda
06-19-2009, 08:44 PM
I solved the problem...the problem is one of the field name.. in my language "is" (actually iş but we never use pointed letter in code language) means job. i tried to keep job information of user at that field. but mysql complier complied it like "as", "is"...so I changed is like iss and solved the problem...i work for it about 2 days...xD thank you all for triyn' ..xD

Arkh
09-11-2009, 02:58 AM
Getting a Parse Error when attempting to submit my form to my php form processing script.

Parse error: syntax error, unexpected T_VARIABLE in /home/amoodf5/public_html/greatmoods/site/cgi-bin/dealerentryform.php on line 43

Line 43 is the $message, but I don't know what is wrong with it. Any insight on the problem would be greatly appreciated.

Thanks in advance,
Mark



<?php
$myemail = "mark.rupp@greatmoods.com";

$repname = check_input($_POST['repname'],"Sales Rep Name Required");
$dealername = check_input($_POST['dealername'],"Sales Rep Name Required");
$address1 = check_input($_POST['address1']);
$address2 = check_input($_POST['address2']);
$city = check_input($_POST['city']);
$state = check_input($_POST['state']);
$zip = check_input($_POST['zip']);
$weekdayhours = check_input($_POST['weekdayhours']);
$weekendhours = check_input($_POST['weekendhours']);
$otherproducts = check_input($_POST['otherproducts']);
$about = check_input($_POST['about']);

$email = htmlspecialchars($_POST['email']);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))
{
$email = '';
}

$url = htmlspecialchars($_POST['website']);
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i",$url))
{
$url = '';

}

$phone = htmlspecialchars($_POST['website']);
if (preg_match("/\D/",$phone))
{
die("Please enter numbers only for the Phone Number");
}

$fax = htmlspecialchars($_POST['website']);
if (preg_match("/\D/",$fax))
{
die("Please enter numbers only for the Fax Number");
}

$subject = "Dealer Website Request ($repname)"

$message = "Hello! This is a Dealer Request for $dealername from $repname.

Dealer: $dealername

E-mail: $email

Address: $dealername, $address1, $address2, $city, $state $zip

Phone Number: $phone

Fax Number: $fax

About the Company: $about

Other Products: $otherproducts

Weekday Hours: $weekdayhours

Weekend Hours: $weekendhours
";

mail($myemail, $subject, $message);

header('Location: /site/thankyou.php');
exit();

function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}

return $data;
}

function show_error($myError)
{
?>

<html>
<body>

<b>Please correct the following error:</b><br />
<?php echo $myError; ?>

</body>
</html>

<?php
exit();
}
?>