 |
|
|
03-04-2008, 09:49 PM
|
Parse error
|
Posts: 10
Name: Matthew Hartshorn
|
hello again,
MGraphic gave me some help this week-end and looking for more. I moved the site to the live server and the database is local. After getting some help from the client I was able to login. Then the contact page had an error with the security code mgraphic helped me with. After some research I assume that the PHP vr. on the server is older than PHP 4.3, so I removed the code. Now I am receiving a parsing error and pulling hair out I don't have to try and figure out the problem. I appreciate any help I can get.
new code
Code:
<?php
if ($submit) {
$db = mysql_connect("localhost","root","password");
mysql_select_db("database", $db);}
$sql = "
INSERT INTO evwslg (fname, lname, email, typeofservice, address, city, state, zip, mphone, hphone, besttocall)
VALUE (
'" ($_POST['fname']) "',
'" ($_POST['lname']) "',
'" ($_POST['email']) "',
'" ($_POST['typeofservice']) "',
'" ($_POST['address']) "',
'" ($_POST['city']) "',
'" ($_POST['state']) "',
'" ($_POST['zip']) "',
'" ($_POST['mphone']) "',
'" ($_POST['hphone']) "',
'" ($_POST['besttocall']) "'
)
";
mysql_query($sql, $conn);
mysql_close($conn);
header('Location: http://www.evwslg.com/contact/thankyou.html');
?>
MGraphics code
Code:
<?php
if ($submit) {
$db = mysql_connect("localhost","root","password");
mysql_select_db("database", $db);}
$sql = "
INSERT INTO evwslg (fname, lname, email, typeofservice, address, city, state, zip, mphone, hphone, besttocall)
VALUE (
'" . mysql_real_escape_string($_POST['fname']) . "',
'" . mysql_real_escape_string($_POST['lname']) . "',
'" . mysql_real_escape_string($_POST['email']) . "',
'" . mysql_real_escape_string($_POST['typeofservice']) . "',
'" . mysql_real_escape_string($_POST['address']) . "',
'" . mysql_real_escape_string($_POST['city']) . "',
'" . mysql_real_escape_string($_POST['state']) . "',
'" . mysql_real_escape_string($_POST['zip']) . "',
'" . mysql_real_escape_string($_POST['mphone']) . "',
'" . mysql_real_escape_string($_POST['hphone']) . "',
'" . mysql_real_escape_string($_POST['besttocall']) . "'
)
";
mysql_query($sql, $conn);
mysql_close($conn);
header('Location: http://www.evwslg.com/contact/thankyou.html');
?>
Contact HTML Form
Code:
<form action="insert.php" method="post" name="form1" target="_parent" id="form1">
<label>First Name<br />
<input name="fname" type="text" id="fname" tabindex="1" maxlength="30" />
</label>
<p>Last name<br />
<label>
<input name="lname" type="text" id="lname" tabindex="2" maxlength="30" />
</label>
</p>
<p>
<label>E-Mail<br />
<input name="email" type="text" id="email" tabindex="3" maxlength="50" />
</label>
</p>
<p>
<label>Type Of Service<br />
<select name="typeofservice" id="typeofservice" tabindex="4">
<option> </option>
<option>Laser Hair Reduction</option>
<option>Affirm Skin Rejuvenation</option>
<option>Wrinkle Reduction</option>
<option>Photo Facials</option>
<option>Vein reduction</option>
<option>Pigmented lesion Reduction</option>
<option>Skin Tightening</option>
<option>Acne Treatment</option>
<option>Stretch Mark Reduction</option>
<option>Medical Chemical Peels</option>
<option>DNA Repair Facials</option>
<option>Organic Facials</option>
<option>Waxing</option>
<option>Specialty Treatments for Expecting Moms</option>
</select>
</label>
</p>
<p>
<label>Street Address<br />
<input name="address" type="text" id="address" tabindex="5" maxlength="20" />
</label>
</p>
<p>
<label>City<br />
<input name="city" type="text" id="city" tabindex="6" maxlength="25" />
</label>
</p>
<p>
<label>State<br />
<select name="state" id="state" tabindex="7">
<option> </option>
<option>AL</option>
<option>AK</option>
<option>AS</option>
<option>AZ</option>
<option>AR</option>
<option>CA</option>
<option>CO</option>
<option>CT</option>
<option>DE</option>
<option>DC</option>
<option>FM</option>
<option>FL</option>
<option>GA</option>
<option>GU</option>
<option>HI</option>
<option>ID</option>
<option>IL</option>
<option>IN</option>
<option>IA</option>
<option>KS</option>
<option>KY</option>
<option>ME</option>
<option>MH</option>
<option>MD</option>
<option>MA</option>
<option>MI</option>
<option>MN</option>
<option>MS</option>
<option>MO</option>
<option>MT</option>
<option>NE</option>
<option>NV</option>
<option>NH</option>
<option>NJ</option>
<option>NM</option>
<option>NY</option>
<option>NC</option>
<option>ND</option>
<option>MP</option>
<option>OH</option>
<option>OK</option>
<option>OR</option>
<option>PW</option>
<option>PA</option>
<option>PR</option>
<option>RI</option>
<option>SC</option>
<option>SD</option>
<option>TN</option>
<option>TX</option>
<option>UT</option>
<option>VT</option>
<option>VI</option>
<option>VA</option>
<option>WA</option>
<option>WV</option>
<option>WI</option>
<option>WY</option>
</select>
</label>
</p>
<p>
<label>Zip Code<br />
<input name="zip" type="text" id="zip" tabindex="8" size="12" maxlength="12" />
</label>
</p>
<p>
<label>Mobile Phone<br />
<input name="mphone" type="text" id="mphone" tabindex="9" size="13" maxlength="13" />
</label>
</p>
<p>Home Phone<br />
<label>
<input name="hphone" type="text" id="hphone" tabindex="10" size="13" maxlength="13" />
</label>
</p>
<p>
<label>Best time to Call<br />
<select name="besttocall" id="besttocall" tabindex="11">
<option> </option>
<option>Morning</option>
<option>Afternoon</option>
<option>Evening</option>
</select>
</label>
</p>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label>
</p>
</form>
|
|
|
|
03-04-2008, 10:53 PM
|
Re: Parse error
|
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
|
Oops, I seen a few mistakes that I had made...
PHP Code:
<?php if ($submit) { $db = mysql_connect("localhost","root","password"); mysql_select_db("database", $db); $sql = " INSERT INTO evwslg (fname, lname, email, typeofservice, address, city, state, zip, mphone, hphone, besttocall) VALUE ( '" ($_POST['fname']) "', '" ($_POST['lname']) "', '" ($_POST['email']) "', '" ($_POST['typeofservice']) "', '" ($_POST['address']) "', '" ($_POST['city']) "', '" ($_POST['state']) "', '" ($_POST['zip']) "', '" ($_POST['mphone']) "', '" ($_POST['hphone']) "', '" ($_POST['besttocall']) "' ) "; mysql_query($sql, $db); mysql_close($db); header('Location: http://www.evwslg.com/contact/thankyou.html'); } ?>
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|
|
|
|
03-04-2008, 11:10 PM
|
Re: Parse error
|
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
|
I think you should consider using mysql_real_escape_string() to help prevent malicious abuse.
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|
|
|
|
03-04-2008, 11:32 PM
|
Re: Parse error
|
Posts: 10
Name: Matthew Hartshorn
|
Im running it through NuSphere PhpEd debugger and it keeps coming up with the parsing error on the super global bracket "(". The exact error message is: Error: E_Parse syntax error, unexpected '(' at insert.php line 10
I just downloaded the program so not sure if there's anything that suggests a correction.
I did remove the code lines with the superglobals, but no clue if it actually posted to the DB. Here's what I have left and also receiving an error message for the header.
Warning: Cannot add header information - headers already sent by....
Code:
<?php
if ($submit) {
$db = mysql_connect("localhost","root","password");
mysql_select_db("database", $db);
$sql = "
INSERT INTO evwslg (fname, lname, email, typeofservice, address, city, state, zip, mphone, hphone, besttocall)";
mysql_query($sql, $db);
mysql_close($db);
header('Location: http://www.evwslg.com/contact/thankyou.html');
}
?>
|
|
|
|
03-04-2008, 11:37 PM
|
Re: Parse error
|
Posts: 10
Name: Matthew Hartshorn
|
Quote:
Originally Posted by mgraphic
I think you should consider using mysql_real_escape_string() to help prevent malicious abuse.
|
Almost positive the server is running an earlier version of PHP it is 7 years old. After the last few days I'm thinking just doing resellers, so I have more control and knowledge about the server.
|
|
|
|
03-04-2008, 11:50 PM
|
Re: Parse error
|
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
|
Then try removing the () from the post data.
Also be sure there is no output or spaces before the opening <?php
PHP Code:
if ($submit) { $db = mysql_connect("localhost","root","password"); mysql_select_db("database", $db); $sql = " INSERT INTO evwslg (fname, lname, email, typeofservice, address, city, state, zip, mphone, hphone, besttocall) VALUE ( '" $_POST['fname'] "', '" $_POST['lname'] "', '" $_POST['email'] "', '" $_POST['typeofservice'] "', '" $_POST['address'] "', '" $_POST['city'] "', '" $_POST['state'] "', '" $_POST['zip'] "', '" $_POST['mphone'] "', '" $_POST['hphone'] "', '" $_POST['besttocall'] "' ) "; mysql_query($sql, $db); mysql_close($db); header('Location: http://www.evwslg.com/contact/thankyou.html'); }
__________________
<mgraphic /> - I don't have a solution but I admire the problem.
|
|
|
|
03-05-2008, 07:17 PM
|
Re: Parse error
|
Posts: 10
Name: Matthew Hartshorn
|
Yeah tried that, tried finding unnecessary spaces, etc... the pressure is off me now and can start from day one again learning PHP and other coding. NO clue why it wasn't working. I am going to set up a home network and find out where I went wrong.
|
|
|
|
03-06-2008, 02:33 AM
|
Re: Parse error
|
Posts: 137
Name: Casey
|
Try this:
Code:
<?php
if ($submit) {
$db = mysql_connect("localhost","root","password");
mysql_select_db("database", $db);}
$sql = "
INSERT INTO evwslg (fname, lname, email, typeofservice, address, city, state, zip, mphone, hphone, besttocall)
VALUE (
'" .$_POST['fname']. "',
'" .$_POST['lname']. "',
'" .$_POST['email']. "',
'" .$_POST['typeofservice']. "',
'" .$_POST['address']. "',
'" .$_POST['city']. "',
'" .$_POST['state']. "',
'" .$_POST['zip']. "',
'" .$_POST['mphone']. "',
'" .$_POST['hphone']. "',
'" .$_POST['besttocall']. "'
)
";
mysql_query($sql, $conn);
mysql_close($conn);
header('Location: http://www.evwslg.com/contact/thankyou.html');
?>
Notice the Periods instead of Parenthesis. I ran the script and it took me to your thank you page. It should also be noted that I had to remove this:
Code:
mysql_query($sql, $conn);
mysql_close($conn);
since in the script you provided you did not have a variable set for $conn which I can only assume there is more to the program than what you provided. However, this worked fine for me and should for you as well.
Last edited by choskins102; 03-06-2008 at 02:48 AM..
|
|
|
|
03-06-2008, 11:22 PM
|
Re: Parse error
|
Posts: 10
Name: Matthew Hartshorn
|
that worked choskim.
Only reason i had close tags was from what I was trying. Awesome thank you.
|
|
|
|
|
« Reply to Parse error
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|