Follow us on Twitter!
The measure of a mans life is not how well he dies, but how well he lives.
Thursday, April 24, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 16
Guests Online: 14
Members Online: 2

Registered Members: 82890
Newest Member: ByteofPython
Latest Articles
View Thread

HellBound Hackers | Computer General | Webmasters Lounge

Author

PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-05-07 14:05
Code
<?php
mysql_connect("localhost","root" , "password") or die (mysql_error());

mysql_select_db("tutorial1") or die (mysql_error());


$personaldata = array("name" => $_POST['name'], "age" => $_POST['age'], "sex" => $_POST['sex']);

mysql_query("INSERT INTO personalinformation (name, age, sex) VALUES('$personaldata[name]', '$personaldata[age]', '$personaldata[sex]')") or die(mysql_error());

echo "You've submited this information. <br> name:" .$personaldata['name']. "<br> Age:" .$personaldata['age']. "<br> Sex:" .$personaldata['sex'].

?>




Heres my code. Now I must say that the sex option is a select menu in the html.

The error I get is $end error. and when I add the ; at my last echo, I get unexpected ; on that last echo line, and the $end error is on the line of " ?>" which is weird.

Thanks for any help you guys can give me!


Author

RE: PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-05-07 15:06
should be a semi colon at the end of your second last line, not a dot.
Author

RE: PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-05-07 16:31
Now I have a little bug. For some reason when I Submit the info. my last echo has a little problem seems like it not showing the information it's just blank as the last echo says it shouldn't. When I check my database. The only value I get is The sex value not the others :S

Thanks




Edited by on 27-05-07 16:33
Author

RE: PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-05-07 18:17
Try echoing all your $_POST variables, think something goes wrong there then.
Author

RE: PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-05-07 14:31
You've submited this information.
name:
Age:
Sex: M


again only the sex is the seen one. Keep in mind that the sex is a select meny where name and age are text fields.


Author

RE: PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 31-05-07 22:32
try this
Code

<?php
mysql_connect("localhost","root" , "password" or die (mysql_error());

mysql_select_db("tutorial1" or die (mysql_error());


$personaldata = array("name" => $_POST['name'], "age" => $_POST['age'], "sex" => $_POST['sex']);

mysql_query("INSERT INTO personalinformation (name, age, sex) VALUES('$personaldata['name']', '$personaldata['age']', '$personaldata['sex']'" or die(mysql_error());

echo "You've submited this information. <br> name:" .$personaldata['name']. "<br> Age:" .$personaldata['age']. "<br> Sex:" .$personaldata['sex'];

?>






Author

RE: PHP&SQL Problems! $end error or unexpected ; error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 03-06-07 19:58
It's because of how you are inserting them into the database. You are trying to use the array with constants meaning that instead of using $array['key'] you are doing $array[key] which reference to two different values. So just do:

Code

mysql_query("INSERT INTO  table (field, field, field) VALUES ('" . $array['key'] . "', '" . $array['key'] . "', '" . $array['key'] . "')");





That should insert it into the database correctly.




Edited by on 03-06-07 19:59