I have a simple html form built that a user puts name, company,
address..blah..blah, you know - and it dumps it all in a db I created
in MySQL.
Below is my php script:
<?php
if (strlen($name) > 2) {
$dbh=mysql_connect ("localhost", "reseller", "PASSWORD HERE") or die
('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("autonomi_reseller ");
$date = time();
$insertq = "INSERT INTO apply SET first_name = '$first_name', last_name
= '$last_name', email = '$email', company = '$company', address1 =
'$address1', address2 = '$address2', city = '$city', state_province =
'$state_province', zip_or_postalcode = '$zip_or_postalcode', phone =
'$phone'";
mysql_query($insertq) or die (mysql_error());
echo '<html><head><title>Redirect</title><script language="javascript">
<!--
location.redirect("http://url.com here");
-->
</script>
';
}
?>
--------------------------------------------------------------------
Whne I execute the script after I filled in all the info on the webpage
form, I get this error:
Parse error: parse error, unexpected $ in
/home/autonomi/public_html/php/app.php on line 23
What am I missing in my php script? It's driving me nuts trying to
figure it out. Thanks in advance. 5 1414
what's with the '; after </script>? st******@gmail.com wrote: I have a simple html form built that a user puts name, company, address..blah..blah, you know - and it dumps it all in a db I created in MySQL.
Below is my php script:
<?php
if (strlen($name) > 2) {
$dbh=mysql_connect ("localhost", "reseller", "PASSWORD HERE") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("autonomi_reseller ");
$date = time();
$insertq = "INSERT INTO apply SET first_name = '$first_name', last_name = '$last_name', email = '$email', company = '$company', address1 = '$address1', address2 = '$address2', city = '$city', state_province = '$state_province', zip_or_postalcode = '$zip_or_postalcode', phone = '$phone'"; mysql_query($insertq) or die (mysql_error());
echo '<html><head><title>Redirect</title><script language="javascript"> <!--
location.redirect("http://url.com here");
--> </script> '; }
?> --------------------------------------------------------------------
Whne I execute the script after I filled in all the info on the webpage form, I get this error:
Parse error: parse error, unexpected $ in /home/autonomi/public_html/php/app.php on line 23
It would be nice if you marked which line is line 23 in your script...
Cheers,
NC
"kevincw01" <ke*******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... what's with the '; after </script>?
it closes the string to be echoed
ahh yes, thx. well i echo NC's request. Which is line 23? st******@gmail.com wrote: I have a simple html form built that a user puts name, company, address..blah..blah, you know - and it dumps it all in a db I created in MySQL.
Below is my php script:
<?php
if (strlen($name) > 2) {
$dbh=mysql_connect ("localhost", "reseller", "PASSWORD HERE") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("autonomi_reseller ");
$date = time();
$insertq = "INSERT INTO apply SET first_name = '$first_name', last_name = '$last_name', email = '$email', company = '$company', address1 = '$address1', address2 = '$address2', city = '$city', state_province = '$state_province', zip_or_postalcode = '$zip_or_postalcode', phone = '$phone'"; mysql_query($insertq) or die (mysql_error());
echo '<html><head><title>Redirect</title><script language="javascript"> <!--
location.redirect("http://url.com here");
--> </script> '; }
?> --------------------------------------------------------------------
Whne I execute the script after I filled in all the info on the webpage form, I get this error:
Parse error: parse error, unexpected $ in /home/autonomi/public_html/php/app.php on line 23
What am I missing in my php script? It's driving me nuts trying to figure it out. Thanks in advance.
I ran the code you posted through a couple of PHP IDEs I have and the
code is syntactically correct. I am wondering why you are doing all that
messy stuff with javascript just to get the redirect when there is a PHP
function for it. See my reworked example below:
<pre>
<?php
if (strlen($name) > 2) {
$dbh = mysql_connect("localhost", "reseller", "PASSWORD HERE")
or die('I cannot connect to the database because: '
.mysql_error());
mysql_select_db("autonomi_reseller", $dbh);
$date = time(); // not sure why this is done
$insertq = "insert into apply( "
."first_name, "
."last_name, "
."email, "
."company, "
."address1, "
."address2, "
."city, "
."state_province, "
."zip_or_postalcode, "
."phone "
.") values ( "
."'$first_name', "
."'$last_name', "
."'$email' "
."'$company', "
."'$address1', "
."'$address2', "
."'$city', "
."'$state_province', "
."'$zip_or_postalcode', "
."'$phone' "
.") ";
mysql_query($insertq, $dbh)
or die(mysql_error());
header('http://url.com here');
}
?>
</pre>
I find setting out the insert the way I have makes it much easier to see
what is meant by the insert. You could do the same with the 'set column
= $column' form if you prefer it.
Even though the specification of the database connection is optional, I
like to put it in anyway because I am very paranoid when I code.
Hope this helps.
-david- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Quest Master |
last post by:
I am interested in developing an application where the user has an
ample amount of power to customize the application to their needs, and
I feel this would best be accomplished if a scripting...
|
by: Rodd Snook |
last post by:
I have an application which makes extensive use of the
Scripting.Dictionary object. I'm not doing anything silly like putting
them outside the page scope -- just creating quite a few of them and...
|
by: What-a-Tool |
last post by:
Dim MyMsg
Set MyMsg = server.createObject("Scripting.Dictionary")
MyMsg.Add "KeyVal1", "My Message1"
MyMsg.Add "KeyVal2", "My Message2"
MyMsg.Add "KeyVal3", "My Message3"
for i = 1 To...
|
by: bt |
last post by:
I am just beginning with asp and have gotten an error that I need some
help with. I posted a pair of files to an online ASP host server. The
files are in the same directory; one is readfile.asp...
|
by: Vaibhav |
last post by:
dear all,
i wonder if someone help me..
i am trying the create a dictionary obejct in asp but its giving
the error
Error Type:
(0x8002801D)
Library not registered
|
by: dito |
last post by:
I have a .asp page that contains an activex componet. When I launch
it in a browser, it returns an error that the viewer is unable to
create it's resource objects. "To rectify this problem,...
|
by: John |
last post by:
Can't get this to work. I'm creating a workaround for the absence of
aspJPEG on my server. I'm using aspUpload but my server only uses aspThumb.
After aspThumb optimizes the original pic the file...
|
by: freemann |
last post by:
Can anyone provide example code showing how to send form results to a results
page, email and a comma delimited file? Notice that I need it going to all
three locations.
Details: I have forms...
|
by: pbd22 |
last post by:
Hi -
I have code that automatically fills tabs on a page. In some cases, a
URL path won't be correct (the folder and files don't exist) and, in
these cases, I want to catch these exceptions and...
|
by: ADezii |
last post by:
The next series of Tips will involve the Microsoft Scripting Runtime Library (Scrrun.dll). This Library is, in my humble opinion, one of the most useful and practical Libraries ever created. With the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |