Re: [PHP-DB] Possible MySQLi extension BUG!. .
Renich Bon Ciric wrote: Firs of all, I wanna say I have spent a whole week looking for answers elsewhere. The reason of this message is to look for a practical solution. I just spent the last 2-3 days converting my entire database (and website) from charset latin1 (ISO-8859-1) to utf8. Although I used the mysql library instead of the mysqli library I believe this should help: SET NAMES 'utf8'; Execute that query before you execute any other query that is going to use characters that are encoded in utf8. If you would like more information on what the above statement does here's the link to the mysql documentation: http://dev.mysql.com/doc/mysql/en/charset-connection.html - Aman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto-generating next id (in order) for an add script. .
I'd recommend you use what mysql provides for this. Auto_increment flag. Here's more information on how to make your id column be an auto_increment primary key. http://dev.mysql.com/doc/mysql/en/example-auto-increment.html - Aman Patel, Sys Admin / Database / Web Devloper, International Outreach x4076 [EMAIL PROTECTED] wrote: Hello, I have a site that allows reporters to enter their articles into a forum. I am then spilling their articles onto the main page from a MySQL dbase via a php script, read LATEST ARTICLES. I am now entering the data myself after they email it to me, however this is becoming more of a task I dont' have time for as the number of articles increase per day. Right now, I have an addarticle.php page where they can enter their information. I have ran a test of this script, and it works great. However, I have been entering the PHP IDs myself in ascending order (i.e. 0005, 0006, 0007) because I can see all of the articles. The reporters however are not able to see these articles, and instead of having them enter a random php ID, I'd like my add script to check for the last ID entered and then enter the number above (i.e add row to table, check PHP ID, if 0007 is last row entered, enter 0008 for php ID for new article). Does anyone know how to add this particular command to a page, and if so, where? Thank you in advance. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Multiselect List. .
Ryan Jameson (USA) wrote: That's not the problem. The problem is referring to the listbox via javascript. It doesn't like the format: formName.listBoxName[].value it has no problem with formName.listBoxName.value but then PHP doesn't seem to handle it correctly. There is a function called MM_findObj which does exactly what you need. I believe it originated from the Macromedia company (hence the MM prefix) - possibly used by Dreamweaver for its scripting purposes, but I digress. Below is the funtion, and whenever you want to refer to oddly named form elements, you call MM_findObj('oddlyNamedFormElement[]') (and it returns an object reference to the form element that you can use normally). function MM_findObj(n, d) { //v4.01 var p, i, x; if (!d) { d = document; } if ((p = n.indexOf('?')) 0 parent.frames.length) { d = parent.frames[n.substring(p+1)].document; n = n.substring(0,p); } if (!(x = d[n]) d.all) { x = d.all[n]; } for (i = 0; !x i d.forms.length; i++) { x = d.forms[i][n]; } for (i = 0; !x d.layers i d.layers.length; i++) { x = MM_findObj(n, d.layers[i].document); } if(!x d.getElementById) { x=d.getElementById(n); } return x; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PEAR - My hosting company killed it. .
Dianne Mead wrote: Hi, I know this is the probably the wrong list for this question, but I'm a bit desperate as my hosting company has disabled PEAR on the server, and I was using it extensively on more than one website... suddenly my weekend looks like a coding nightmare. The hosting service reports a security issue, but no details. Has anyone using PEAR here run into this problem? Is there any potential resolution beyond recoding everything? I'm looking at better than ten sites to recode at this point, so other options would be greatly appreciated. The hosting company didn't give me any warning that this was going to happen. Thanks, Dianne I'd suggest tar/gz'ing your development server's PEAR directory (most likely /usr/share/pear if under *nix), and uploading that to somewhere in your production server's space (hopefully at non-web accessible location). You can than add that directory to your include_path (either through php.ini or .htaccess). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] R6025 Error. .
Ng Hwee Hwee wrote: hi all, this R6025 error is driving me nuts!!! anyone who can help me? thanx a million!! Full error details are described here: http://support.microsoft.com/default.aspx?scid=kb;en-us;125749 To the best of my knowledge and after some googling, I found three possible causes for this error in internet explorer: 1) A javascript in your page is generating the error. 2) A plugin you are using in internet explorer is causing the error. 3) Some application is causing the error when it interacts with Internet explorer or vice versa (eg. office toolbar, acrobat toolbar, norton av hooks etc). The only suggestion I have to troubleshoot this is to shut off each of these one by one and see if you can reproduce the error. I haven't experienced this myself, so I don't have more suggestions on fixing it. thanks, Aman Patel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem Using Sessions. .. .
Shawn Singh wrote: that was very helpful...Thank you. One question I have is that I want to ensure that my admin page cannot get accessed unless a variable that was registered upon a successful login has been passed into the session...what can I do to ensure this? There are several ways to do this. The simplest way is to authenticate once and store a authentication flag in the session. You can set this authentication flag to true if the log-in was sucesfull. On the administration page, you an just access the flag to see if the user is permitted (i.e. logged on). You can do this using the $_SESSION super global, something like this: (pseudo php code) login.php ... if ( authentication sucessfull ) /* username/password matched*/ { $_SESSION['auth'] = true; // redirect to admin page } else { Display login page with error. } ... admin.php ... if ( $_SESSION['auth'] ) { Show administration page. } else { Display login page with error. } ... - NB: Make sure you use Header() redirects BEFORE your scripts prints anything. Otherwise you'll keep getting the warning/error Warning: Cannot modify header information ... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem Using Sessions. .
From the PHP help page on session_register() If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. I'm assuming since you compiled and installed PHP 5.0.4 that your register_globals is disabled. I wouldn't recommend enabling it to fix this problem. Instead use $_SESSION super global to register session data. So instead of: session_register(username); try this: $_SESSION['username'] = $username; /* TO SET */ $username = $_SESSION['username']; /* TO GET */ Hope this helps, Aman Shawn Singh wrote: Hey All, I'm fairly new to PHP Programming. I have compiled and installed postgres version 8.0.1, and with that compiled postgres support into my postgres (I'm using PHP version 5.0.4), and I've compiled support for PHP into Apache (version 2.0.53) and all is working (in that I can embed PHP into my HTML documents and get the expected results). Recently I started working on a website in which I would like there to be an administration page where the person who is logged in can add and delete records. I figured that the best way to do this would be to establish a session, (at the login page) then if the user login is successful, I would then register the username and password and redirect the user to the admin page. I chose not to use cookies, b/c everyone may not have cookies enabled on their browser and I didn't want that to be a hurdle that a user would have to jump over. I've written the code but when I try to login to the site I get this message: Warning: Cannot modify header information - headers already sent by (output started at /export/home/www/htdocs/login.php:13) in /export/home/www/htdocs/login.php on line 25 Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 Information I've seen on the web for these types of messages would indicate that I don't have a /tmp directory, but such is not the case. Other messages have indicated that my session variables are not getting written to /tmp, but that is not true either, as I have seen them in there...as I see entries such as: sess_ec2249332b8b29863f161461cf8c1409 So, I'm guessing that there aren't problems with my /tmp filesystem. Please excuse the lack of style as I have mainly been trying to hack out something, but plan to clean it up later. My source code for the login page is as follows: snip -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php3 and oracle9i client libraries doesn't compile... .
As far as I know, PSA is the internal product name for Plesk Server Administration software. Here's the product page if you need more information. http://www.sw-soft.com/ru/products/psa/ Why would PHP need PSA? I have no idea (apart from the fact that psa seems to be just another web server(tm) probably based on apache). Aman Martin Norland wrote: neil smith wrote: I'm using this command to configure php3 ./configure --with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-versioning --enable-track-vars --with-oci8=/u01/app/oracle/product/9.2.0.4 --with-oracle=/u01/app/oracle/product/9.2.0.4 --enable-sigchild that works ok. But when I type make it eventually fails with this error: gcc -shared -o libphp3.so mod_php3.o libmodphp3-so.a -L/usr/local/lib -L/u01/app/oracle/product/9.2.0.4/lib -lclntsh -lpsa -lcore4 -lnlsrtl3 -lclntsh -ldl -lm -lpthread -lnsl -lirc -lgdbm -lpam -lm -ldl -lcrypt -lresolv -Wl,--version-script=/usr/php/php-3.0.18/php.map -Wl,-rpath /u01/app/oracle/product/9.2.0.4/lib /usr/bin/ld: cannot find -lpsa collect2: ld returned 1 exit status apxs:Break: Command failed with rc=1 make: *** [libphp3.so] Error 1 I don't understand enough about this compilation process to know what lpsa is and why it can't find it. Does anybody know how I can get php3 to work with oracle 9i client libraries? thanks in advance to anyone who can help. -lpsa means it's trying to link a library named 'psa' - off the top of my head I can't say what that is, and a brief googling is proving less than useful. --- end section where I am 'useful', on to questioning rant --- Can I ask why you're using such an old version of php? If it's for a legacy application I can understand, but it seems like you're giving up a LOT to stay on php3. In any case - looking at the release dates for the two: http://www.oracle.com/technology/software/products/oracle9i/index.html Oracle9i Database Release 2 Enterprise/Standard Edition for Linux New (26-Mar-04) http://www.php.net/releases.php 3.0.x (latest) # Released: 20 Oct 2000 I'd say you'd be better off trying your legacy app under php4 and moving to that. If it's simply a register globals issue, then you're no safer in php3 than you would be in php4 with it turned on, so that's not a reason to stay back. good luck determining what psa is, I have to run to a meeting but I may try looking again later. cheers, -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Headers sent error msg on one server but not the other.... .
Check that there is no output generated before your script hits the Header() function calls. The most common mistake I've noticed is that if you require() or include() many files before you call Header(), and if there is any content outside of the ?php ? tags in the includ()'ed or require()'d files (eg. a carraige return at the end, or a space after the ?. Check for that and that should fix your problem. Craig Hoffman wrote: Hey Folks, I have a script that times out the session if there is no activity in a certain amount of time. If there is no activity the HEADER() redirects to the logout page and kills the session. Everything works fine on our test server, but when I test the script on the production server, I get an error HEADERS ALREADY SENT... after no activity. I know all this stuff needs to be on top, before any XHTML. The test server has reg globals = OFF and the production server has them set to ON. I can't change the any PHP.INI settings on the production server. Both servers are running PHP 4.3.10. Other than that PHP installation is close to identical. Any ideas / thoughts on what's causing the production server to send this error out? Something to steer me in the right direction... I'm attaching a code snippet to look at: if (mysql_num_rows($result) 0) { $_SESSION[valid_user] = $email; } elseif ($t_timestamp $c_timestamp) { HEADER(Location: logout.php); exit; } Best, CH __ Craig Hoffman ICQ / iChat: m0untaind0g __ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] retrieve enum values
Melanie, Here's a function that will parse the SHOW COLUMNS query output and will return an array of ENUM values, after you have the array it should be easy to generate the html code you need. The first two parameters are self explanatory (the table name and the column name). Hope this helps, define(G_ENUM_COLUMN,4); // set this to 4 if you are using SET column type, and 4 for ENUM column type. /* Return the SET or ENUM set of values. $p_start can be 3 for SET... or 4 for ENUM... */ function get_set_column_values ( $p_table, $p_colname ) { $result = mysql_query($query); $arr = mysql_fetch_array( doQuery( SHOW COLUMNS FROM $p_table LIKE '$p_colname'; ) ); $value = substr( $arr[1], G_ENUM_COLUMN ); eval( \$the_array = array $value; ); // let eval do all the parsing work. return $the_array; } - Aman Patel, Sys Admin / Database / Web Developer, International Outreach x4076 -Original Message- From: mel list_php [mailto:[EMAIL PROTECTED] Sent: Thursday, April 14, 2005 7:54 AM To: php-db@lists.php.net Subject: [PHP-DB] retrieve enum values Hi! I have a column type enum in mysql. At the moment the possible values are 1,2 and 3. I make a form for my user to modify that value, something like: select option value='1'1/option option value='2'2/option option value='3'3/option /select I may need to add a value 4 to the enum, and in that case I would like to avoid modifying the code. I would like to know it it is possible to have something like: select possible_enum_values from table ... and then having a loop through these values. I can't select distinct values in that column because one value may not exist yet and I don't want to have fake records. I found that in the mysql doc and was wondering if there is an already implemented php function intsead of having to parse: If you want to determine all possible values for an ENUM column, use SHOW COLUMNS FROM tbl_name LIKE enum_col and parse the ENUM definition in the second column of the output. Any idea? Melanie _ It's fast, it's easy and it's free. Get MSN Messenger today! http://www.msn.co.uk/messenger -- 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] Re: paginating : optimising queries
I've run in to this situation before. And it turns out that the extra pre-count query is not worth it. So the steps become: 1) Do your main query and fetch the results. 2) Use the count of results obtained in step 1. 3) Calculate pagination numbers. 4) Use array_slice to limit the results to a page window calculated in step 3. Hope this helps. - Aman Patel, Sys Admin / Database / Web Developer, International Outreach x4076 -Original Message- From: Zouari Fourat [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 22, 2005 10:03 AM To: php-db@lists.php.net Subject: [PHP-DB] Re: paginating : optimising queries no one can help me outta here ? On Mon, 21 Mar 2005 01:58:10 +0100, Zouari Fourat [EMAIL PROTECTED] wrote: Hello, i made my own paginating class, it permit me to paginate over selected data and let me do good presentation (page 1, page 2 ...) i use adodb for db related functions, my application should show in every page this set of informations : Total results : Z, Total page : Y, You are on the page number X. To show thos informations, i must do a count on all the table, example : the query built from the form submitted by the user is : select * from table where column=value and column like 'value%' to paginate that query, i'll add some LIMIT or LIMIT OFFSET for pgsql (it's adodb frontend) so i'll get only the data for one page ! i use this query : select count(*) from table with that global count i can calculate how much pages i have by dividing count on the number of rows to show per page. with this method, the server will suffer for big tables... it's a method that i've made without consulting what people do, can you do this with only ONE query so i can optimise ? thank you for your help -- 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