[PHP-DB] PHP, MySQL and WML! Checking a database column for a particular value!
Hi, I am trying to check for the existance of a certain value (ie $login, taken from my first PHP page: member.php) in the "first" column of my database "mydb. The value of "$login" is passed from member.php. My data base "mydb" contains 1 table called emplyoees which was created as follows: CREATE TABLE employees ( id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id)); INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager'); My code is as follows: member.php: "; echo "http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?> http://localhost/WAP/member2.php?login=$(login)"/> Please enter your First Name: member2.php: "; echo "http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?> When I enter a valid "first" name ie Bob it works fine and outputs everything to the screen. If I enter a name that does not exist in the database it just puts up and empty WML page. Is there a way of checking for the existance of $login in the "first" column of my database and if so doing somethin for example printing out "Success" other wise, if it is not a member printing out something different? I have tried saying if ($result = 'Resource id #2){ print (Success); }else{ print (Fail); } because if i echo out $login that is the value i get but it doesn't work. If anyone has any alternative suggestions as an approach to this problem then I am all ears!! Thank you, Kevin.
[PHP-DB] PHP, MySQL and WML! Checking a database column for a particular value!
Hi, I am trying to check for the existance of a certain value (ie $login, taken from my first PHP page: member.php) in the "first" column of my database "mydb. The value of "$login" is passed from member.php. My data base "mydb" contains 1 table called emplyoees which was created as follows: CREATE TABLE employees ( id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id)); INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager'); My code is as follows: member.php: "; echo "http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?> http://localhost/WAP/member2.php?login=$(login)"/> Please enter your First Name: member2.php: "; echo "http://www.wapforum.org/DTD/wml_1.1.xml\">"; ?> When I enter a valid "first" name ie Bob it works fine and outputs everything to the screen. If I enter a name that does not exist in the database it just puts up and empty WML page. Is there a way of checking for the existance of $login in the "first" column of my database and if so doing somethin for example printing out "Success" other wise, if it is not a member printing out something different? I have tried saying if ($result = 'Resource id #2){ print (Success); }else{ print (Fail); } because if i echo out $login that is the value i get but it doesn't work. If anyone has any alternative suggestions as an approach to this problem then I am all ears!! Thank you, Kevin.
Re: [PHP-DB] PHP, MySQL and WML!
>INSERT INTO employees (first,last,address,position) VALUES >('$(first)','$(last)','$(address)','$(position)') >is because in WML variables are stored as $(first) and not just $first like in >HTHML. >Somewhere between >$sql = "INSERT INTO employees (first,last,address,position) > > VALUES ('$(first)','$(last)','$(address)','$(position)')"; > >AND > > $result = mysql_db_query ("mydb", $sql); >it seemes to loose the values of all my variables!! >I would appreciate any help anyone can be since I have been working in this >for 2 days solid now and haven't managed to fix it (though i have managed to >recreate it in many different ways!!) WML variables are not PHP variables. The way I do this is to have get the input in a card like you have it then submit it to another php script that processes it just like it would process any form data submitted. Doing it this way they all end up as regular php variables. For example, gather all your data as you have it, but instead of sending it to another card where you process it send it to a php script which handles it. This script need not even be wap compliant, it can just process and that's it, but you'd probably want it to be to confirm that it did what it did. In your case, where myurl is the url to a script which contains something like: \n"); echo("http://www.wapforum.org/DTD/wml_1.1.xml\">\n\n"); echo("\n"); ?> '; ?> = "To dwell within Samsara, however, is to be subject to the works of those mighty among dreamers." - Mahasamatman, in Zelazny's "Lord of Light" Andrew Apold -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] PHP, MySQL and WML!
Hi, I am trying to update a MySQL database using a PHP script embeded in a WML page. Here is my code: The following is register2.php: > > > > > > > > > > > > First Name: > Last Name: > Address: > Position: > > > > > > > $db = mysql_connect("localhost", "root"); > > mysql_select_db("mydb",$db); > > $sql = "INSERT INTO employees (first,last,address,position) > VALUES ('$(first)','$(last)','$(address)','$(position)')"; > > $result = mysql_db_query ("mydb", $sql); > > echo "$sql"; > ?> > > > > Then I run register (to see if the database has been updated)! > The following is register.php: > > > > // send wml headers > header("Content-type: text/vnd.wap.wml"); > echo ""; > echo " . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; > ?> > > > > > > > > > $db = mysql_connect("localhost", "root"); > mysql_select_db("mydb",$db); > $result = mysql_query("SELECT * FROM employees",$db); > printf("First Name: %s\n", mysql_result($result,0,"first")); > printf("Last Name: %s\n", mysql_result($result,0,"last")); > printf("Address: %s\n", mysql_result($result,0,"address")); > printf("Position: %s\n", mysql_result($result,0,"position")); > > > > In the the following line: printf("First Name: %s\n", mysql_result($result,0,"first")); the 0 is the row we want to view. Since I created an empty database this value is initially 0. If i run register2.php a second time I have to increment this 0 to 1 before running register.php and so on. You will see in register2.php that i have echied out $sql and it has the correct value for exammple: INSERT INTO employees (first,last,address,position) VALUES ('Kevin','Connolly','Somewhere','Manager') but when I look at the database it has: First Name: Last Name: Address: Position: instead of First Name: Kevin Last Name: Connolly Address: Somewhere Position: Manager The reason I have INSERT INTO employees (first,last,address,position) VALUES ('$(first)','$(last)','$(address)','$(position)') is because in WML variables are stored as $(first) and not just $first like in HTHML. Somewhere between $sql = "INSERT INTO employees (first,last,address,position) > VALUES ('$(first)','$(last)','$(address)','$(position)')"; AND > $result = mysql_db_query ("mydb", $sql); it seemes to loose the values of all my variables!! I would appreciate any help anyone can be since I have been working in this for 2 days solid now and haven't managed to fix it (though i have managed to recreate it in many different ways!!) Thank you, Kevin. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]