RE: [PHP-DB] dropping one word from column entries
Naw do your parsing in PHP..try to lessen the load on the DB server any way you can... ed At 09:11 AM 5/30/2002 +0800, Beau Lebens wrote: A cleaner option might be to do this before you get it to PHP at all, via your SQL query. Check out the string functions available, there are a number of substring-style things available, string position etc. HTH Beau // -Original Message- // From: Ed Gorski [mailto:[EMAIL PROTECTED]] // Sent: Thursday, 30 May 2002 12:09 AM // To: Jen Swofford; php-db@lists. php. net // Subject: Re: [PHP-DB] dropping one word from column entries // // // use: // // $name=Mouse Housing Products; // $name=str_replace(Products,,$name); // // also the RTFM() function works too // // ed // // At 11:06 AM 5/29/2002 -0500, Jen Swofford wrote: // I'm having a problem with this and suppose I'm looking for // a handout. :| // // I am displaying names of product categories. The names of // the categories // are: // // Bird Cages // Cat Toys // Chinchilla Housing Products // Dog Leashes // Ferret Housing Products // Mouse Housing Products // // What I want to do when displaying the names is to drop // Products whenever // it appears. What I want do display on the page instead is: // // Bird Cages // Cat Toys // Chinchilla Housing // Dog Leashes // Ferret Housing // Mouse Housing // // And no, changing the names of the categories in the // database is not an // option. :) I'm completely missing the boat on this one... // any help? // // Jen Swofford // [EMAIL PROTECTED] // // // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, visit: http://www.php.net/unsub.php // // // -- // PHP Database Mailing List (http://www.php.net/) // To unsubscribe, visit: http://www.php.net/unsub.php // -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql exclusion in php
You need to parse the string and PHP and generate the appropriate query based on that parsing... ed At 09:22 PM 5/29/2002 -0700, Chris Payne wrote: Hi there everyone, How can I do a search which excludes certain words if they put a - in the search string? I can do a search easily, but if they put a - infront of a word in the string, how can I then get MySQL to search all entries EXCEPT where the word with a - next to it appears? Thanks for everything. Chris -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP-DB] how to pull array out?
Well put Julie ed At 10:39 AM 5/30/2002 -0700, Julie Meloni wrote: Jas (and anyone else) - With all due respect, you're acting like a troll. Posting a question, getting MANY correct answers, then reposting the question and bitching about not understanding the answers, well, that's troll-like. Granted, many responses on this list over the past while have been sarcastic, but usually also have the answer in them. The tone comes from people asking the questions not doing their own homework. e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html Mailing lists such as this one are not intended to give people verbatim answers to their problems, such as I have to write an application for my university class, please do it for me and the like. Instead, these lists will help those who attempt to help themselves. The fact of the matter is, RTFM is the right answer. The very simplistic method of reading the results of a MySQL query are right there in the manual, in the MySQL query functions section. Also, they're in zillions of tutorials, any basic book on PHP, and so on. In short: 1) connect to db server -- mysql_connect() 2) select db -- mysql_select_db() 3) issue query -- mysql_query() 4) from there you get a result identifier. You feed that into mysql_result() or mysql_fetch_array() or mysql_fetch_row() Read the manual for the differences -- including examples. You say: J rest of us we rely on examples, etc to get it done. They ARE in the manual, which is pretty much the best manual out there for just about anything. Good luck, - Julie -- Julie Meloni -- [EMAIL PROTECTED] -- www.thickbook.com Find Sams Teach Yourself MySQL in 24 Hours at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: Re[2]: [PHP-DB] how to pull array out?
People use to suppress errors / warning messagesI know I use it a lot with obdc and SQL SERVER procedures... ed At 02:32 PM 5/30/2002 -0400, Leotta, Natalie (NCI/IMS) wrote: From what I've seen on the PHP.net site, it doesn't look like people use the @ in @mysql_query, and I know that I don't use it for sybase_query. Where did it come from? Assuming that's not the problem, I'd try printing out everything. Right after your while, print $row - it should say array, then try printing $row[0] and see if that works. Then try printing $row['user_id']. You may also want to try doing a SELECT with the fieldnames, instead of just the *. Also, make sure you're typing the field names correctly - they are case sensitive. Hopefully one of these suggestions will help you. -Natalie -Original Message- From: Jas [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 30, 2002 2:18 PM To: [EMAIL PROTECTED] Subject: Re: Re[2]: [PHP-DB] how to pull array out? Ok, given there are people out there that expect people to do the work for them, however if you look at my original post (today) you will see that I have queried the database, feed the results into an array, then called the array elements into my form, however simple this may be for you it is still not pulling out the results of the array into my form. I do believe I am missing something, and doing homework is a part of my everyday routine trying to develop web based apps. The code again: $table = auth_users; // names the table to query correct? $record = @mysql_query(SELECT * FROM $table WHERE user_id = '$user_id',$dbh); // pulls all records in relation to $user_id correct? while ($row = mysql_fetch_array($record)) { // pulls results of query into an array correct? $user_id = $row['user_id']; // assigns unique names for my different editable regions correct? $f_name = $row['f_name']; $l_name = $row['l_name']; $email_addy = $row['email_addy']; $un = $row['un']; $pw = $row['pw']; } $var_form .= form name=\$user_id\ method=\post\ action=\del_account.php\ bEdit Account $user_id/bbr // echoes the $user_id that is going to be edited correct? First Name:input type=\text\ name=\f_name\ size=\30\ maxlength=\30\ value=\$f_name\br // displays text box to edit with $f_name variable from resulting array correct? Last Name:input type=\text\ name=\l_name\ size=\30\ maxlength=\30\ value=\$l_name\br // displays text box to edit with $l_name variable from resulting array correct? Email:input type=\text\ name=\email_addy\ size=\30\ maxlength=\30\ value=\$email_addy\br // displays text box to edit with $email_addy variable from resulting array correct? User Name:input type=\text\ name=\un\ size=\30\ maxlength=\30\ value=\$un\br // displays text box to edit with $un variable from resulting array correct? Password:input type=\password\ name=\pw\ size=\30\ maxlength=\30\br // displays text box to edit with $pw variable from resulting array correct? Confirm Password:input type=\password\ name=\cpw\ size=\30\ maxlength=\30\ nbsp;input type=\submit\ name=\add\ value=\edit user\nbsp;nbsp;input type=\reset\ name=\reset\ value=\reset\; Any help or examples are appreciated. Please understand I am trying to learn this scripting language and RTFM does not help as most of the time I post here as a LAST resort, i.e. after I have indeed RTFM'ed. Thanks again, Jas Julie Meloni [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Jas (and anyone else) - With all due respect, you're acting like a troll. Posting a question, getting MANY correct answers, then reposting the question and bitching about not understanding the answers, well, that's troll-like. Granted, many responses on this list over the past while have been sarcastic, but usually also have the answer in them. The tone comes from people asking the questions not doing their own homework. e.g. http://www.tuxedo.org/~esr/faqs/smart-questions.html Mailing lists such as this one are not intended to give people verbatim answers to their problems, such as I have to write an application for my university class, please do it for me and the like. Instead, these lists will help those who attempt to help themselves. The fact of the matter is, RTFM is the right answer. The very simplistic method of reading the results of a MySQL query are right there in the manual, in the MySQL query functions section. Also, they're in zillions of tutorials, any basic book on PHP, and so on. In short: 1) connect to db server -- mysql_connect() 2) select db -- mysql_select_db() 3) issue query -- mysql_query() 4) from there you get a result identifier. You feed that into mysql_result() or mysql_fetch_array() or mysql_fetch_row() Read the manual for the differences -- including examples. You say: J rest of us we rely on examples, etc to get it done. They ARE in
Re: [PHP-DB] variables gone?
In php.ini you need to turn register_globals on..you also might want to start using the $_GET, $_POST, $_SESSION global arrays ed At 02:49 PM 5/29/2002 +0100, Rob Fraser wrote: Dear All, I am probably doing something silly but I don't know what (story of my life). I have just upgraded to 4.2.1 and now all the variables I post in forms or in query strings are now coming up undefined errors and are in absent. I'm running PHP under IIS 4. What am I doing wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] dropping one word from column entries
use: $name=Mouse Housing Products; $name=str_replace(Products,,$name); also the RTFM() function works too ed At 11:06 AM 5/29/2002 -0500, Jen Swofford wrote: I'm having a problem with this and suppose I'm looking for a handout. :| I am displaying names of product categories. The names of the categories are: Bird Cages Cat Toys Chinchilla Housing Products Dog Leashes Ferret Housing Products Mouse Housing Products What I want to do when displaying the names is to drop Products whenever it appears. What I want do display on the page instead is: Bird Cages Cat Toys Chinchilla Housing Dog Leashes Ferret Housing Mouse Housing And no, changing the names of the categories in the database is not an option. :) I'm completely missing the boat on this one... any help? Jen Swofford [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Error? new set of eyes...
Why don't you try this instead: while(list($id, $2d, $3d, $web, $prog, $tut, $proj)=mysql_fetch_array($portfolio)) { do whatever.. } the list construct only works with numerical arrays and it might not like the $section array (doesn't it get stored as number indicies AND column names? That might generate that error). But if you need that section array later, we can try a different approach.. ed At 07:15 AM 5/28/2002 -0600, Jas wrote: Hello all, I have an error and I will be darned if I know why. Here is the code: ?php require '/path/to/database/connection/class/db.php'; $table = portfolio; $portfolio = mysql_query(SELECT * FROM $table,$dbh); while ($sections = mysql_fetch_array($portfolio)) { list($id, $2d, $3d, $web, $prog, $tut, $proj) = $sections; // I think the error is on this line. } ? Then I just echo the contents of the database array like so. ?php echo $2d; ? // this is line 69 And this is the error I am recieving: Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /localhost/portfolio.php on line 169 Any help would be great!! Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Edmund Gorski Programmer / Analyst WWW Coordinator Dept. District Office 727-341-3181 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] creating errors
try just: $sql = INSERT INTO $table_name (f_name,l_name,email_addy,un,pw) VALUES ('$f_name','$l_name','$email_addy','$un', 'PASSWORD('$pw')'; ed At 09:55 AM 5/28/2002 -0600, Jas wrote: I am trying to add an insert into a table and set one of the fields to a password hash, however I am recieving errors: $sql = INSERT INTO $table_name (f_name,l_name,email_addy,un,pw) VALUES ('$f_name','$l_name','$email_addy','$un', 'pw=PASSWORD('$pw')'; Is there any reason this would not work? Jas -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php