|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP5 - Trouble with getting data from a MySQL database
Hello all,
Here is what I am trying to do. A user enters the first name of somebody and that persons first name, last name, and age is displayed. I am using PHP and MySQL. I know the database is set up and working because I can see it in PHP My Admin and I can insert data to it. What is wrong? I think it has something to do with the this part, because this where i edited the tutorial i got the code from: PHP Code:
When I try to run this code, I get this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\select.php on line 17 Below is the code I am trying to get to work: Here is the html code for the form: Code:
<html> <body> <form action="select.php" method="post"> Firstname: <input type="text" name="firstname" /> <input type="submit" /> </form> </body> </html> Here is the PHP code: PHP Code:
Thanks for your help |
|
#2
|
||||
|
||||
|
Do this:
PHP Code:
__________________
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002 Think we're being rude? Please read this. Trying to argue intelligently? Please read this. |
|
#3
|
|||
|
|||
|
Dan,
Thanks for responding. When I substituted your code for mine I got this error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\select.php on line 14 here is the code again PHP Code:
|
|
#4
|
|||
|
|||
|
PHP Code:
ManiacDan had a comma after the mysql_real_escape_string instead of a period. I also did some housecleaning to make the code a little nicer. Cheers ![]()
__________________
Your man, DaWizman Visit DaWizman Dot Com(Under Construction) Check out Central Intelligence Forums |
|
#5
|
|||
|
|||
|
Thanks guys.
I changed my code around a bit. now I have a database of States and the the colleges in them. I want a user to select the state via a drop down menu. Then when the user goes to select a college, they are presented with only the colleges that correspond to that state. My problem is that I can't figure out the syntax to get the colleges to appear in a drop down menu without getting errors. Here is the error message I get: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\Drop.php on line 49 (The error refers to the PHP code) This is my HTML code: Code:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> select your state: <form action="Drop.php" method="post"> <select name="State"> <option value="NY">NY</option> <option value="ND">ND</option> </select> <input type="submit" /> </form> <form action="" method=""> <select name="College"> <option value="Select College">Select College</option> </select> <input type="submit" /> </form> </body> </html> Here is my php code, drop.php: PHP Code:
btw, DaWizman, how did you get my code to appear vertically as opposed to horizontally? PS: line 49 refers to this line of my code PHP Code:
What's a good online resource for php code syntax? that seems to be what I am having the most trouble with. Thanks |
|
#6
|
||||
|
||||
|
PHP Code:
PHP Code:
__________________
IkoTikashi - ikotikashi.de |
|
#7
|
|||
|
|||
|
Thank you, it my code works now!!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > PHP5 - Trouble with getting data from a MySQL database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|