Re: [PHP-DB] empty query
In a message dated 1/25/2003 10:24:34 PM Pacific Standard Time, [EMAIL PROTECTED] writes: i have unsuccessfully tried for three days to write, re-write something that will insert data into my db and ashamedly have failed again. at one point i was able to echo values and see that they were in fact passing from my form. now i can't even get that. anyway, if you could take a look at this and tell me where i'm going wrong i will greatly appreciate it. thank you... addison ? session_start(); if (@$auth != yes) include(config.php); Is $auth a session variable? If so, is register_globals turned on? If not, you should probably be using $_SESSION['auth']. Janet -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] empty query
thank you so much for responding... i added this: { echo $key, $valuebr; } underneath function storeForm($formdata,$ads) and it is now displaying this: year, 1971 make, chevy model, impala color, green mileage, condition, none price, other, Ad may not exceed 25 words. contact, [EMAIL PROTECTED] next_, Submit Your Ad which is what i entered into the form except it is not passing the category, subcategory info that was selected from the two previous pages. and, in the table the data goes into needs to have a category and subcategory id. also, i don't know why i am getting the next_,Submit Your Ad values passed. again, i really appreciate your time. best regards, addison ellis On Sunday 26 January 2003 14:31, Addison Ellis wrote: hello, i have unsuccessfully tried for three days to write, re-write something that will insert data into my db and ashamedly have failed again. at one point i was able to echo values and see that they were in fact passing from my form. now i can't even get that. anyway, if you could take a look at this and tell me where i'm going wrong i will greatly appreciate it. thank you... addison ? session_start(); if (@$auth != yes) include(config.php); function storeForm($formdata,$ads) Are you saying that now $formdata is empty?? If it is, where are you getting $formdata from? [snip] $result = mysql_query($query) or die (Couldn't execute query.); Don't use die(), use: $result = mysql_query($query) or echo Couldn't execute query. . mysql_error(); -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Now here's something you're really going to like! -- Rocket J. Squirrel */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED]
[PHP-DB] dates and updates recommendation?
Hiya. I'm looking for some design advice. I have a number of tables whose data consist of configuration details and parameters that are incorporated into config files for various server applications. For example, a table of customers' email address forwarding info, so a PHP application can be used to add/modify/remove email forwarding in a MySQL table, and a small script is used to build a fresh sendmail virtusertable whenever there are updates to the table. Each of the tables contains data that reflect configuration of the servers (POP3 mailboxes, FTP users, Apache module directives, etc). Each table has a field called changed which gets updated with the current date/time every time the data is changed. Due to lack of planning, some tables store dates as DATETIME, and others store it as an unsigned INT containing the epoch second. I want to standardize on one or the other, and I don't know which direction to go. So what's the best way to store a date? I've always liked storing epoch seconds as INTs, and leaving the translation to/from a human-readable date up to the application, but aside from the relative unreadability of this, are there any significant disadvantages to this method, aside from the rollover problem in 2038? (The S32b bug?) Would I be better off spending a few bytes extra per record and storing things as DATETIME rather than an INT? If I'm looking at the possibily making the application more database-portable in the future, are there gotchas I should be aware of with any particular field types? Thanks. :) -- Paul Chvostek [EMAIL PROTECTED] Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Cutting strings
Hi I have values in my table but for one of the fields I would only like to display the first 5 chars instead of 15 how is this possiable? -- Kind Regards, Chezney -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Cutting strings
Hi from the manual http://www.mysql.com/doc/en/String_functions.html LEFT(str,len) Returns the leftmost len characters from the string str: mysql SELECT LEFT('foobarbar', 5); - 'fooba' HTH Peter -Original Message- From: Chezney [mailto:[EMAIL PROTECTED]] Sent: 26 January 2003 09:08 To: [EMAIL PROTECTED] Subject: [PHP-DB] Cutting strings Hi I have values in my table but for one of the fields I would only like to display the first 5 chars instead of 15 how is this possiable? -- Kind Regards, Chezney -- 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] empty query
On Sunday 26 January 2003 16:14, Addison Ellis wrote: Please do not top-post. i added this: { echo $key, $valuebr; } underneath function storeForm($formdata,$ads) and it is now displaying this: year, 1971 make, chevy model, impala color, green mileage, condition, none price, other, Ad may not exceed 25 words. contact, [EMAIL PROTECTED] next_, Submit Your Ad But this contradicts your initial assertion that you wasn't able to echo any values from $formdata? which is what i entered into the form except it is not passing the category, subcategory info that was selected from the two previous pages. From _TWO_ previous pages? How are you carrying forward the values category subcategory? If you're not carrying them forward then it shouldn't come as a great surprise that they're not available in the latter pages. You need to pass those values along either using hidden field elements in your form or by placing them into session variables. and, in the table the data goes into needs to have a category and subcategory id. also, i don't know why i am getting the next_,Submit Your Ad values passed. I would hazard a guess and say that next_ is the name of a button and Submit Your Ad is it's value? As it is part of the form and you're programmatically (or indiscriminately) extracting everything from $_POST (or equivalent) then that is why you end up with it. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* You have an ability to sense and know higher truth. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] dates and updates recommendation?
On Sunday 26 January 2003 17:02, Paul Chvostek wrote: So what's the best way to store a date? I've always liked storing epoch seconds as INTs, and leaving the translation to/from a human-readable date up to the application, but aside from the relative unreadability of this, are there any significant disadvantages to this method, aside from the rollover problem in 2038? (The S32b bug?) Would I be better off spending a few bytes extra per record and storing things as DATETIME rather than an INT? If I'm looking at the possibily making the application more database-portable in the future, are there gotchas I should be aware of with any particular field types? I think it really depends on where you think you would be doing most of your date manipulations. If most will be done within your SQL queries then use the native DBMS date formats (as a plus MySQL has loads of useful date functions). If your date stuff will mostly be done in PHP then use unix timestamps. On the whole I would stick to a DBMS native date format because: - it's human readable - built-in date functions - not limited to post epoch dates -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* If Machiavelli were a hacker, he'd have worked for the CSSG. -- Phil Lapsley */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] empty query
first, i must apologize as i am very new at this... and... i really appreciate your help. addison On Sunday 26 January 2003 16:14, Addison Ellis wrote: Please do not top-post. Sorry here... i added this: { echo $key, $valuebr; } underneath function storeForm($formdata,$ads) and it is now displaying this: year, 1971 make, chevy model, impala color, green mileage, condition, none price, other, Ad may not exceed 25 words. contact, [EMAIL PROTECTED] next_, Submit Your Ad But this contradicts your initial assertion that you wasn't able to echo any values from $formdata? correct... i am able to echo values again. which is what i entered into the form except it is not passing the category, subcategory info that was selected from the two previous pages. From _TWO_ previous pages? How are you carrying forward the values category subcategory? If you're not carrying them forward then it shouldn't come as a great surprise that they're not available in the latter pages. You need to pass those values along either using hidden field elements in your form or by placing them into session variables. i had the following to carry forward cat and subcat values: ? session_start(); if (@$auth != yes) { header(Location: login.php); exit(); } include(config.php); $scobj = mysql_db_query($dbname,select * from subcategory where id=$subcategory) or die (mysql_error()); $scrow = mysql_fetch_object($scobj); $cobj = mysql_db_query($dbname,select * from category where id=$scrow-category) or die (mysql_error()); $crow = mysql_fetch_object($cobj); $sql = SELECT first_name,last_name FROM accounts WHERE email='$logname'; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) extract($row); and, in the table the data goes into needs to have a category and subcategory id. also, i don't know why i am getting the next_,Submit Your Ad values passed. I would hazard a guess and say that next_ is the name of a button and Submit Your Ad is it's value? As it is part of the form and you're programmatically (or indiscriminately) extracting everything from $_POST (or equivalent) then that is why you end up with it. how am i to get rid of it. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* You have an ability to sense and know higher truth. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED]
Re: [PHP-DB] empty query
On Sunday 26 January 2003 18:59, Addison Ellis wrote: correct... i am able to echo values again. Hmm, okay :-) i had the following to carry forward cat and subcat values: ? session_start(); if (@$auth != yes) { header(Location: login.php); exit(); } include(config.php); $scobj = mysql_db_query($dbname,select * from subcategory where id=$subcategory) or die (mysql_error()); $scrow = mysql_fetch_object($scobj); $cobj = mysql_db_query($dbname,select * from category where id=$scrow-category) or die (mysql_error()); $crow = mysql_fetch_object($cobj); $sql = SELECT first_name,last_name FROM accounts WHERE email='$logname'; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) extract($row); I don't see anything in that code which would carry the category and subcategory forward, UNLESS $scrow and $crow are registered as session variables. I would hazard a guess and say that next_ is the name of a button and Submit Your Ad is it's value? As it is part of the form and you're programmatically (or indiscriminately) extracting everything from $_POST (or equivalent) then that is why you end up with it. how am i to get rid of it. Don't put it into $formdata! Remember you're the one who is putting it in there! Presumably at some point you have some code which will insert the contents of $formdata into your database. If that code is properly written then the presence (or otherwise) of next_ should not affect its operation. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Once upon a time, four AMPHIBIOUS HOG CALLERS attacked a family of DEFENSELESS, SENSITIVE COIN COLLECTORS and brought DOWN their PROPERTY VALUES!! */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] empty query
whew! is there a tutorial you know of that might help me? in essence i have page 1 select category, page two select subcategory, page 3 fill out the form, click submit, data is entered into database, user is directed to a new page. i thought from this php 4.1 book that i was doing that. :-) i guess not. anyway... thank you very much, again. addison On Sunday 26 January 2003 18:59, Addison Ellis wrote: correct... i am able to echo values again. Hmm, okay :-) i had the following to carry forward cat and subcat values: ? session_start(); if (@$auth != yes) { header(Location: login.php); exit(); } include(config.php); $scobj = mysql_db_query($dbname,select * from subcategory where id=$subcategory) or die (mysql_error()); $scrow = mysql_fetch_object($scobj); $cobj = mysql_db_query($dbname,select * from category where id=$scrow-category) or die (mysql_error()); $crow = mysql_fetch_object($cobj); $sql = SELECT first_name,last_name FROM accounts WHERE email='$logname'; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) extract($row); I don't see anything in that code which would carry the category and subcategory forward, UNLESS $scrow and $crow are registered as session variables. again, from this new php 4.1 book, i am following the examples and guidelines. i guess that since register_globals is turned on on the server they are passing.? I would hazard a guess and say that next_ is the name of a button and Submit Your Ad is it's value? As it is part of the form and you're programmatically (or indiscriminately) extracting everything from $_POST (or equivalent) then that is why you end up with it. how am i to get rid of it. Don't put it into $formdata! Remember you're the one who is putting it in there! i guess i am not sure how to keep it out of $formdata. again, the book... addison Presumably at some point you have some code which will insert the contents of $formdata into your database. If that code is properly written then the presence (or otherwise) of next_ should not affect its operation. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Once upon a time, four AMPHIBIOUS HOG CALLERS attacked a family of DEFENSELESS, SENSITIVE COIN COLLECTORS and brought DOWN their PROPERTY VALUES!! */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Addison Ellis small independent publishing co. 114 B 29th Avenue North Nashville, TN 37203 (615) 321-1791 [EMAIL PROTECTED] [EMAIL PROTECTED] subsidiaries of small independent publishing co. [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Cutting strings
Use the substr function string substr ( string string, int start [, int length] ) http://be.php.net/manual/en/function.substr.php Greetz, Michael -Original Message- From: Chezney [mailto:[EMAIL PROTECTED]] Sent: dimanche 26 janvier 2003 10:08 To: [EMAIL PROTECTED] Subject: [PHP-DB] Cutting strings Hi I have values in my table but for one of the fields I would only like to display the first 5 chars instead of 15 how is this possiable? -- Kind Regards, Chezney -- 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] dates and updates recommendation?
[snip] Would I be better off spending a few bytes extra per record and storing things as DATETIME rather than an INT? If I'm looking at the possibily making the application more database-portable in the future, are there gotchas I should be aware of with any particular field types? This has been argued back and forth quite a few times on here. If you want your application portable, use an INT column, store UNIX timestamps, and have PHP do all of the conversion/comparisons for you. If you're just going to be using MySQL, then I definitely recommend using it's date/time format. MySQL has a wealth of date/time functions that make it really easy to get exactly what you want out of the table. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Using strlen and substr to Shorten DB Results
I have a script that I am working on that pulls info from a database: -- Code -- $getscname = mysql_query(SELECT * FROM subcat WHERE subcatid = '$subcatid') or die (Couldn't get the info.br.mysql_error()); while($sub_cat = mysql_fetch_array($getscname)){ $subcat_id = $sub_cat['subcatid']; $subcat_name = $sub_cat['subcatname']; echo 'a href=subcat.php?catid='.$catid.'sc='.$subcat_id.''.$subcat_name.'/a nbsp;nbsp;nbsp;nbsp;|nbsp;nbsp;nbsp;nbsp;'; } -- Code -- At the end of each link, a pipe is printed. I want to take the pipe off of the last result, so that the page will prit out: SubCat1 | SubCat2 | SubCat3 I've tried using strlen substr to do this, but it cuts the pipe off of all the results, not the last one. Any suggestions? TIA. Jami [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Find and replace in a string
Hi list! I have a sting that contains some occurances of {...} sub-strings, where is some text. Which is the way to find and replace the {...} with an other of my own. This sub-strings start with { and end with }. Thanks
[PHP-DB] Re: Using strlen and substr to Shorten DB Results
Try this. PHP arrays are cool! Of course there are tidier ways to implement this, but this is just an example. Adam -- Code -- $getscname = mysql_query(SELECT * FROM subcat WHERE subcatid = '$subcatid') or die (Couldn't get the info.br.mysql_error()); while($sub_cat = mysql_fetch_array($getscname)){ $subcat_id = $sub_cat['subcatid']; $subcat_name = $sub_cat['subcatname']; $arrCats[] = 'a href=subcat.php?catid='.$catid.'sc='.$subcat_id.''.$subcat_name.'/ a'; } echo implode('nbsp;nbsp;nbsp;nbsp;|nbsp;nbsp;nbsp;nbsp;',$arrCats); -- Code -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Find and replace in a string
I have a sting that contains some occurances of {...} sub-strings, where is some text. Which is the way to find and replace the {...} with an other of my own. This sub-strings start with { and end with }. If you know what the text is between { and }, then use $new_str = str_replace({test},replacement,$old_str); If you don't, then you can use a regular expression to match and replace it. ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Using strlen and substr to Shorten DB Results
I have a script that I am working on that pulls info from a database: -- Code -- $getscname = mysql_query(SELECT * FROM subcat WHERE subcatid = '$subcatid') or die (Couldn't get the info.br.mysql_error()); while($sub_cat = mysql_fetch_array($getscname)){ $subcat_id = $sub_cat['subcatid']; $subcat_name = $sub_cat['subcatname']; echo 'a href=subcat.php?catid='.$catid.'sc='.$subcat_id.''.$subcat_name.'/a nbsp;nbsp;nbsp;nbsp;|nbsp;nbsp;nbsp;nbsp;'; } -- Code -- At the end of each link, a pipe is printed. I want to take the pipe off of the last result, so that the page will prit out: SubCat1 | SubCat2 | SubCat3 I've tried using strlen substr to do this, but it cuts the pipe off of all the results, not the last one. Any suggestions? Based on how you're building your string, you'll want to remove the last 25 characters from it to get rid of the last | and all of the nbsp; characters. So, this should work: $fixed_str = substr($old_str,0,-25); Or, you could use a regular expression to match the last | and whatever follows it up to the end of the string. $fixed_str = preg_replace(/|[^|]*$/,,$old_str); ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Find and replace in a string
On Mon, Jan 27, 2003 at 12:57:10AM +0200, Nikos Gatsis wrote: Hi list! I have a sting that contains some occurances of {...} sub-strings, where is some text. Which is the way to find and replace the {...} with an other of my own. This sub-strings start with { and end with }. You could try something with a regular expression like: $new = ereg('[^{]*{([^}]*)}.*', '\\1', $oldstring); which will match only the first word inside curly braces, or if $oldstring contains multiple strings in curly braces, maybe: $newarray = split('}?[^{]*{', $oldstring . '{'); and then parse the array, and you'll probably want to toss [0], as it will contain the data before the first left-curly-brace. This method needs a trailing left-curly-brace appended to $oldstring because the regexp relies on it to mark the field. You could alternately turn this around as: $newarray = split('}[^{]*{?', '}' . $oldstring); which is probably the cleanest way to do this, given the extent to which you've described the data so far. Note that split() will work just fine on multi-line arrays, including fields split over multiple lines. If you want to process your data line-by-line, you'd need to wrap it. The better you can predict the input data, the cleaner the code you can use to parse it. Learn the regexps. -- Paul Chvostek [EMAIL PROTECTED] Operations / Abuse / Whatever it.canada, hosting and development http://www.it.ca/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Storing previous versions?
I'm planning to use a wiki-style help system for my website. I've considered using existing open-source wiki systems, but it would be too much work to get them hooked up with my user system, etc. Like most wikis, previous versions of articles will be stored. I'm looking for ideas as to the best data structure for the previous versions (one table for articles, and another for each version of them?). Also, any ideas for having it not take up huge ammounts of disk space? Storing the difference between the next version and the old one, perhaps? -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Calling functions recursively: recursive PHP functions
Roberto Jason thank you for your comments. Please note the question at the end of this email. I searched on recursive PHP functions and found: [thelist] recursive PHP functions Rob Wilson thelist at lists.evolt.org Mon Sep 16 11:00:01 2002 * Previous message: [thelist] recursive PHP functions * Next message: [thelist] pop up window for image without MSIE image resize * Return to the message index sorted by: [ date ] [ thread ] [ subject ] [ author ] That should read ?php function recursive ($n) { if ($n 10) { return $n; } echo N = . $n . BR; $n++; return recursive ($n); } echo The result:.recursive(1).br; ? With the important line being the : return recursive ( $n ); This allows you to unwind the recursion correctly. HTH Rob * Under www.zend.com/manual chapter 8 Variable scope a mention of recursion: Static variables also provide one way to deal with recursive functions. A recursive function is one which calls itself. Care must be taken when writing a recursive function because it is possible to make it recurse indefinitely. You must make sure you have an adequate way of terminating the recursion. The following simple function recursively counts to 10, using the static variable $count to know when to stop: ?php function Test() { static $count = 0; $count++; echo $count; if ($count 10) { Test (); } $count--; } ? *** Interesting but I am still lost as I need some help with methods/functions within objects: In the above example do I need to access Test() by: if ($count 10) { this-Test (); Comments please. Kevin Gordon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Calling functions recursively: recursive PHP functions
[snip] ?php function Test() { static $count = 0; $count++; echo $count; if ($count 10) { Test (); } $count--; } ? ** * Interesting but I am still lost as I need some help with methods/functions within objects: In the above example do I need to access Test() by: if ($count 10) { this-Test (); Yes, without the space: $this-Test(); ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php