[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]
[PHP-DB] Fw: PHP, MySQL and WML! Checking a database column for a particular value!
SORRY IF YOU ALREADY GOT THIS BUT I DIDN'T RECEIVE IT EVEN THOUGH I AM ON THE MAILING LIST SO I WASN'T SURE IF IT SENT OR NOT!! 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.
[PHP-DB] $result = true or false??
Hi, $db = mysql_connect("localhost", "root"); mysql_select_db("mydb",$db); $sql = "SELECT * FROM employees where first = '$login'"; $result = mysql_db_query ("mydb", $sql); echo "$result"; If I run this cose then $result always = Resource id #2 even if $login is not a member of the database. Is there anyway I can get it to output true if $login is a member and false if $login is not a member? or at least get $result to be different if $login is in the database to that when it is not? Thanks, Kevin.
[PHP-DB] php and mysql file insertion!
Hi, I have a MySQL database that is updated using a PHP script. It stores a members details (name, address etc.) I also want it to store a file (a member photo to be exact). Is this possible? Any help is much appreciated! Thanks, Kevin.
Re: [PHP-DB] php and mysql file insertion!
Yeah, but I also want t do some encrpyption stuff and I have to store a *.pgp file! I suppose I could do the same for this but I would prefer to have them both in the database! -Kev. - Original Message - From: "David Balatero" <[EMAIL PROTECTED]> To: "Rick Emery" <[EMAIL PROTECTED]> Cc: "'Kevin Connolly'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, March 06, 2001 8:03 PM Subject: Re: [PHP-DB] php and mysql file insertion! > Couldn't you also just store the image on the server, then put the path to the > image (http://www.mysite.com/images/thatimg.jpg) in the database? > > -- David Balatero > > Rick Emery wrote: > > > Yes. There's another tutorial on the site which addresses that question. > > > > rick > > -Original Message- > > From: Kevin Connolly [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, March 06, 2001 1:39 PM > > To: Rick Emery > > Subject: Re: [PHP-DB] php and mysql file insertion! > > > > great thanks! > > Will I be able to save different file types do you know? > > wull it work for non-picture files? > > Thanks again, > > Kev. > > - Original Message - > > From: "Rick Emery" <[EMAIL PROTECTED]> > > To: "'Kevin Connolly'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > > Sent: Tuesday, March 06, 2001 7:28 PM > > Subject: RE: [PHP-DB] php and mysql file insertion! > > > > > That link just failed me... > > > > > > Anyway, go to http://www.weberdev.com. Select the "Articles and > > Tutorials" > > > link at the left. Go to the "PHP" link. > > > Select the "Graphics" link. Select the article "Saving Images in MySQL". > > > > > > rick > > > -Original Message- > > > From: Rick Emery > > > Sent: Tuesday, March 06, 2001 1:23 PM > > > To: 'Kevin Connolly'; '[EMAIL PROTECTED]' > > > Subject: RE: [PHP-DB] php and mysql file insertion! > > > > > > > > > http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=1825 > > > > > > -Original Message- > > > From: Kevin Connolly [mailto:[EMAIL PROTECTED]] > > > Sent: Tuesday, March 06, 2001 12:28 PM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP-DB] php and mysql file insertion! > > > > > > > > > Hi, > > > I have a MySQL database that is updated using a PHP script. It stores a > > > members details (name, address etc.) I also want it to store a file (a > > > member photo to be exact). Is this possible? > > > Any help is much appreciated! > > > Thanks, > > > 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] > > > > > > > -- > > 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 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] Help! Want to unsubscribe!
Hi, I am trying to unsubscribe from this mailing list (I keep going over my allotted space on the mail server!) but can't seem to do it! I have gone to the remove link on the phpbuilder web page (twice) but still the mails arrive! Anybody know how to unsubscribe? Thanks to everyone who has helped me during my stay! -Kev.
[PHP-DB] continuously view database updates.
Hi, I am doing a college project which involves using PHP scripts to update a MySQL database. For demonstration purposes I would like the new updated table in my Database to be shown each time it is updates without me having to go to the command prompt window and type in select * from members; for example! I will have the command window open for the demo. Thanks Kev.
[PHP-DB] Multiple rows for one column in a MySQL table?
Hi, Is it possible to have multiple rows for one column of a MySQL databes? and if so how would I insert another row into the column in question? eg: idNamePhone Number 1Kev 123123 2John 234234 345345 3 Paul 789789 Thanks, Kev.