Hi,
I'm beginning to learn PHP/MySQL, i have problem 'parse error' when using
'mysql_query' although it was simple code, like this :
=
1 ?php
2 $host = localhost;
3 $user = root;
4 $pass = alpha;
5 $konek = mysql_connect($host,$user,$pass);
6 if (!$konek) {
7 die
Add a ; to the end of line 16.
On Sun, 17 Apr 2005, Bagus Nugroho wrote:
Hi,
I'm beginning to learn PHP/MySQL, i have problem 'parse error' when
using 'mysql_query' although it was simple code, like this :
=
1 ?php
2 $host = localhost;
3 $user = root;
4 $pass = alpha;
5 $konek =
Error:
Parse error: parse error, expecting `']'' in
/usr/local/apache/htdocs/UP/index.php on line 871
Line 871:
mysql_query(INSERT INTO domainregistrations (domain,type,years,price)
VALUES
Perhaps it doesn't like the fact that you don't have quotes around your
array keys?
--Sam
Tyler Longren wrote:
Error:
Parse error: parse error, expecting `']'' in
/usr/local/apache/htdocs/UP/index.php on line 871
Line 871:
mysql_query(INSERT INTO domainregistrations
Sorry, should have mentioned that I tried quoting them already. That
gives a T_VARIABLES parse error.
Thanks for the reply,
Tyler
On Mon, 2003-12-22 at 12:30, Sam Masiello wrote:
Perhaps it doesn't like the fact that you don't have quotes around your
array keys?
--Sam
Tyler Longren
[snip]
Sorry, should have mentioned that I tried quoting them already. That
gives a T_VARIABLES parse error.
Thanks for the reply,
Tyler
[/snip]
What happens if you comment out the mysql statement and just echo the
variables?
echo $_POST[domainregister_domain$i]
Tyler Longren wrote:
Error:
Parse error: parse error, expecting `']'' in
/usr/local/apache/htdocs/UP/index.php on line 871
('$_POST[domainregister_domain$i]',
If you're going to be creating array keys like that, break out of the
string to do it.
(' . $_POST['domainregister_domain' . $i] . ', ...
Hi Matt,
I put this right above like 871:
print brbr$_POST[domainregister_domain$i]brbr;
So now that print line is 871. It produces the exact same error as
the mysql_query() line.
The reason I'm doin it like this is cuz I'm dynamically generating
forms, and lots of the fields are the same,
Doing this fixed it:
mysql_query(INSERT INTO domainregistrations (domain,type,years,price)
VALUES
('$_POST[domainregister_domain]$i','$_POST[domainregister_type]$i','$_POST[domainregister_years]$i','$_POST[domainregister_price]$i'));
I just moved the $i to the outside of the [] and it works now.
[snip]
I put this right above like 871:
print brbr$_POST[domainregister_domain$i]brbr;
So now that print line is 871. It produces the exact same error as
the mysql_query() line.
[/snip]
I should have mentioned this in my last email. You should try a
print_r of the $_POST array.
print pre;
Tyler Longren wrote:
Hi Matt,
I put this right above like 871:
print brbr$_POST[domainregister_domain$i]brbr;
So now that print line is 871. It produces the exact same error as
the mysql_query() line.
The reason I'm doin it like this is cuz I'm dynamically generating
forms, and lots of the
11 matches
Mail list logo