[PHP-DB] Re: MySQL executes several times the same request
Loïc moisy wrote: Hi Everyone ! I've coded a php site for a musical store. At the end of every page, before closing the connection, I send an UPDATE request to increment a statistical tool. Recently I saw weird results, so I tried to understand. Looking in my logs, I saw that this request could be sent several times, arbitrary - can be 5 times or 8 or whatever... So my counter is incremented from 4 to 8 times. The server seems to resend the whole requestes several times. I have read all of my scripts, even coded some trace code, and sure there is no loop. The code seems like that: $counter++; $SQL = "UPDATE statistics SET VALUE (`counter` = $counter)" $res = mysql_query($SQL); mysql_closedb($DB); So, I do not see anything strange. Can u help me ? My own thought about it is something like a buffer not empty or something like that. Thanks ! We had a problem like this on our site for a while. It turned out that soneone had put an empty image tag on the site which was causing the browser to go to the same page *again*. Check to make sure that all of your images have the src attribute filled out. -- paperCrane -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] MySQL executes several times the same request
Hi Everyone ! I've coded a php site for a musical store. At the end of every page, before closing the connection, I send an UPDATE request to increment a statistical tool. Recently I saw weird results, so I tried to understand. Looking in my logs, I saw that this request could be sent several times, arbitrary - can be 5 times or 8 or whatever... So my counter is incremented from 4 to 8 times. The server seems to resend the whole requestes several times. I have read all of my scripts, even coded some trace code, and sure there is no loop. The code seems like that: $counter++; $SQL = "UPDATE statistics SET VALUE (`counter` = $counter)" $res = mysql_query($SQL); mysql_closedb($DB); So, I do not see anything strange. Can u help me ? My own thought about it is something like a buffer not empty or something like that. Thanks ! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Oracle Client Libraries for Linux
Folks -- I've been trying to figure out where the Oracle client libraries live, but I'm confused as hell. I've read the PHP-DB archives, and everyone keeps talking about installing the client libraries (libclntsh et al), and how that's all you need for Oracle 9i PHP support. Great -- but which options presented horribly by Oracle do I download? On this page: http://otn.oracle.com/software/products/oracle9i/index.html It lists: Oracle9i Release 2 (9.2.0.4) Oracle9i Database Release 2 Enterprise/Standard Edition for Linux x86-64 New (03-May-04) Oracle9i Database Release 2 Enterprise/Standard Edition for Linux New (26-Mar-04) Oracle9i Release 2 (9.2.0.2) Oracle9i Database Release 2 Enterprise/Standard/Personal/Client Edition for Windows XP 2003/Windows Server 2003 (64-bit) Oracle9i Database Release 2 Enterprise/Standard Edition for HP-UX/IA64 (v9.2.0.2) Oracle9i Database Release 2 Enterprise/Standard Edition for HP Alpha OpenVMS Oracle9i Database Release 2 Enterprise/Standard Edition for Linux/IA64, Release 2 (v9.2.0.2) Oracle9i Release 2 (9.2.0.1) Oracle9i Database Release 2 Enterprise/Standard/Personal/Client Edition for Windows Server 2003 (32-bit) Oracle9i Database Release 2 Enterprise/Standard/Personal Edition for Windows NT/2000/XP Oracle9i Database Release 2 Enterprise/Standard Edition for Sun SPARC Solaris (32-bit) Oracle9i Database Release 2 Enterprise Edition for Sun SPARC Solaris (64-bit) Oracle9i Database Release 2 Enterprise/Standard Edition for HP-UX Oracle9i Database Release 2 Enterprise/Standard Edition for Compaq Tru64 Oracle9i Database Release 2 Enterprise/Standard Edition for AIX Oracle9i Database Release 2 Enterprise/Standard Edition for AIX-Based 5L Systems Oracle9i Database Release 2 Enterprise Edition for Linux/390 Oracle9i Database Release 2 Client for Windows 98/NT/2000/XP Oracle9i Release 2 - Developer's Releases Oracle9i Database Release 2 for IBM Power based Linux New! [01-Dec-03] Oracle9i Developer Release 1 (9.2.0.3.0) for Linux / AMD64 Oracle9i Database Release 2 Enterprise Edition for Apple Mac OS X Version 10.2 Jaguar Oracle9i Release 1 (9.0.1) Oracle9i Release 1 (9.0.1) Enterprise Edition (all platforms) Oracle9i Personal Edition for Microsoft Windows 98 Oracle9i Release 1 - Developer's Releases Oracle9i Enterprise Edition for z/Linux, Release 1 - Developer's Release I'm running Linux RH Enterprise 3 on this server, and the Oracle box is remote. My original assumption is to download the second link, 9iR2 for Linux. However, this is 1.5GB worth of a download for three friggin drivers. What the hell? All of the clients are for Windows, Even the 9.0.1 release is 1.1GB. What do I need to download from Oracle to get the drivers for PHP? Please don't just say "go to otn.oracle.com and download the client" because I've been there and cannot for the life of me find it. I don't have the ability to display X Windows remotely, so whatever solution has got to be command line. I'm at my wits end! I've installed Instant Client, so I have the 10g libraries: /usr/lib/oracle/10.1.0.2/client/lib --> ll total 109664 drwxr-xr-x2 root root 4096 Jun 14 12:36 ./ drwxr-xr-x4 root root 4096 Jun 14 12:36 ../ -rw-r--r--2 root root 1417242 Feb 23 19:32 classes12.jar -rw-r--r--1 root root 1353 Feb 23 19:32 glogin.sql -rwxr-xr-x2 root root 13347415 Feb 23 19:32 libclntsh.so.10.1* -rw-r--r--2 root root 2838283 Feb 23 19:32 libnnz10.so -rw-r--r--2 root root 969980 Feb 23 19:32 libocci.so.10.1 -rwxr-xr-x2 root root 91345295 Feb 23 19:32 libociei.so* -rw-r--r--2 root root96117 Feb 23 19:32 libocijdbc10.so -rw-r--r--1 root root 759920 Feb 23 19:32 libsqlplus.so -rw-r--r--2 root root 1353081 Feb 23 19:32 ojdbc14.jar How do I get connected from a remote PHP+Apache box to Oracle9i on linux? Beckman --- Peter Beckman Internet Guy [EMAIL PROTECTED] http://www.purplecow.com/ --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Delete Subquery
How about: DELETE FROM users WHERE userid IN (SELECT u.userid FROM users AS u LEFT JOIN roles AS r ON (u.roleid = r.roleid) WHERE r.roleid IS NULL LIMIT 1); On Mon, 14 Jun 2004 11:59:25 -0400, Brock Jimmy D Contr 74 MDSS/SGSI <[EMAIL PROTECTED]> wrote: > > I've been able to figure how to use a delete subquery to delete all rows, but how do > I use a delete subquery to delete only one row? > > I have two tables: users and roles with the following fields: > > Users: > > userid > > roleid > > Roles: > > roleid > > I want to be able to delete a rowid from the roles table, but only if the roleid > does not exist in the users table. > > thanks > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Delete Subquery
I've been able to figure how to use a delete subquery to delete all rows, but how do I use a delete subquery to delete only one row? I have two tables: users and roles with the following fields: Users: userid roleid Roles: roleid I want to be able to delete a rowid from the roles table, but only if the roleid does not exist in the users table. thanks
[PHP-DB] Re: Pass into the title meta-tag a variable from an URL Directory Manager
Wathever you are ging to do with meta tag they still are html tag, so as long as you embend the tag in php code it shuold just work fine. "; ?> Any text editor should help you modifying the code by "find & replace" tools. Hope can help ps. FORZA ITALIA AGLI EUROPEI Franciccio "Alessandro Folghera" <[EMAIL PROTECTED]> ha scritto nel messaggio news:[EMAIL PROTECTED] > I hope that phpers will be not angry if I'm posting that maybe stupid > question. > I have the following script, an URL Directory Manager (PHP4 from Wrox Press). > I'd like to pass the variable "category" into the TITLE META TAG from > php_category when I select the corrispondent category_id into the URL > Directory > Manager, i.e. to display the right category everytime I call it from the > script. As I'm an absolute beginner, I'd like someone could suggestme the most > rapid way to do it whitout rewriting all the code. Thanks for all, Alessandro > Tables of MySQL sample_db # Table > structure for table 'php_category' CREATE TABLE php_category ( category > varchar(30) NOT NULL, category_id varchar(15) NOT NULL, num_item int(5) NOT > NULL, PRIMARY KEY (category_id) ); # Table structure for table 'php_directory' > CREATE TABLE php_directory ( url_id int(10) NOT NULL auto_increment, > category_id varchar(15) NOT NULL, title varchar(150) NOT NULL, url > varchar(150) > NOT NULL, description text NOT NULL, registerdate date, hit int(5) NOT NULL, > lastaccesstime timestamp(14), password varchar(20) binary, email varchar(100) > NOT NULL, approved char(1) NOT NULL, PRIMARY KEY (url_id), UNIQUE url (url, > category_id) ); xxx php_directory.inc xx > xx php_directory.php x "; $MYSQL_ERRNO = ''; > $MYSQL_ERROR = ''; function directory_header() { global $new_window_width, > $new_window_height; ?> alert(\"Error: $msg\");history.go(-1)"; > directory_footer(); exit; } function user_message($msg, $url='') { > directory_header(); if(empty($url)) echo "alert(\"$msg\");history.go(-1)"; > else > echo "alert(\"$msg\");self.location.href='$url'"; directory_footer(); exit; } > function get_category_info($category_id) { global $default_dbname, > $category_tablename, $root_category_id, $category_id_length, $welcome_message, > $PHP_SELF; global $link_id; if(!$link_id) $link_id = > db_connect($default_dbname); if($category_id == $root_category_id) { > $category_info_array["category"] = "Top"; $category_info_array["num_item"] > = 0; > $query = "SELECT max(category_id), count(*) FROM $category_tablename WHERE > length(category_id) = $category_id_length"; $result = mysql_query($query); > if(!$result) echo sql_error(); $query_data = mysql_fetch_row($result); > $sibling_id = $query_data[0]; $num_child = $query_data[1]; > $category_info_array["num_child"] = $num_child; if(!$sibling_id) > $next_category_id = '001'; else { $sibling_length = strlen($sibling_id); > $next_category_id = $sibling_id + 1; for($i = strlen($next_category_id); $i > " . > $query_data[0] .""; $parent_array[$j] = $query_data[0]; $j++; } > $category_info_array["href_fullname"] = implode("->", $parent_href_array); > $category_info_array["fullname"] = implode("->", $parent_array); } return > $category_info_array; } function get_url_info($url_id) { global $link_id, > $default_dbname, $directory_tablename; if(!$link_id) $link_id = > db_connect($default_dbname); $query = "SELECT url_id, category_id, title, url, > description,registerdate, date_format(registerdate, '%M, %e, %Y') as > formatted_registerdate, hit, lastaccesstime, date_format(lastaccesstime, '%M, > %e, %Y %r') as formatted_lastaccesstime, password, email, approved FROM > $directory_tablename WHERE url_id = '$url_id'"; $result = mysql_query($query); > if(!$result) echo sql_error(); return mysql_fetch_array($result); } function > search_form($category_id) { global $root_category_id, $PHP_SELF; > if(!isset($category_id)) $category_id = $root_category_id; ?> > "> Search: ">Current Category ">All Categories OR AND > > $category_href_fullname ($num_child_str, $num_item_str) > > \n"; else echo " > > $category_href_fullname ($num_child_str) > > \n"; search_form($category_id); $query = "SELECT category, category_id FROM > $category_tablename WHERE (length(category_id) = $category_depth * > $category_id_length) AND category_id LIKE '$category_id%' ORDER BY category"; > $result = mysql_query($query); if(!$result) echo sql_error(); > if(mysql_num_rows($result) > 0) { ?> > > \n"; echo "\n"; echo "<\"$PHP_SELF?action=show_list> > category_id=$my_category_id\"> $my_category ($num_child_str, > $num_item_str)\n"; > echo "\n"; if(!($i % 2)) echo "\n"; $i++; } if(!($i % 2)) { echo " \n" ; echo > ""; } ?> > > $found_str - Keyword(s): $keywords > > > \n"; if($total_num > 0) echo " > Displaying page $page_num out of $last_page_num > > \n"; $query = "SELECT url_id, category_id, title, url, description, > date_format(registerdate, '%M, %e,
[PHP-DB] Pass into the title meta-tag a variable from an URL Directory Manager
I hope that phpers will be not angry if I'm posting that maybe stupid question. I have the following script, an URL Directory Manager (PHP4 from Wrox Press). I'd like to pass the variable "category" into the TITLE META TAG from php_category when I select the corrispondent category_id into the URL Directory Manager, i.e. to display the right category everytime I call it from the script. As I'm an absolute beginner, I'd like someone could suggestme the most rapid way to do it whitout rewriting all the code. Thanks for all, Alessandro Tables of MySQL sample_db # Table structure for table 'php_category' CREATE TABLE php_category ( category varchar(30) NOT NULL, category_id varchar(15) NOT NULL, num_item int(5) NOT NULL, PRIMARY KEY (category_id) ); # Table structure for table 'php_directory' CREATE TABLE php_directory ( url_id int(10) NOT NULL auto_increment, category_id varchar(15) NOT NULL, title varchar(150) NOT NULL, url varchar(150) NOT NULL, description text NOT NULL, registerdate date, hit int(5) NOT NULL, lastaccesstime timestamp(14), password varchar(20) binary, email varchar(100) NOT NULL, approved char(1) NOT NULL, PRIMARY KEY (url_id), UNIQUE url (url, category_id) ); xxx php_directory.inc xx xx php_directory.php x "; $MYSQL_ERRNO = ''; $MYSQL_ERROR = ''; function directory_header() { global $new_window_width, $new_window_height; ?> alert(\"Error: $msg\");history.go(-1)"; directory_footer(); exit; } function user_message($msg, $url='') { directory_header(); if(empty($url)) echo "alert(\"$msg\");history.go(-1)"; else echo "alert(\"$msg\");self.location.href='$url'"; directory_footer(); exit; } function get_category_info($category_id) { global $default_dbname, $category_tablename, $root_category_id, $category_id_length, $welcome_message, $PHP_SELF; global $link_id; if(!$link_id) $link_id = db_connect($default_dbname); if($category_id == $root_category_id) { $category_info_array["category"] = "Top"; $category_info_array["num_item"] = 0; $query = "SELECT max(category_id), count(*) FROM $category_tablename WHERE length(category_id) = $category_id_length"; $result = mysql_query($query); if(!$result) echo sql_error(); $query_data = mysql_fetch_row($result); $sibling_id = $query_data[0]; $num_child = $query_data[1]; $category_info_array["num_child"] = $num_child; if(!$sibling_id) $next_category_id = '001'; else { $sibling_length = strlen($sibling_id); $next_category_id = $sibling_id + 1; for($i = strlen($next_category_id); $i " . $query_data[0] .""; $parent_array[$j] = $query_data[0]; $j++; } $category_info_array["href_fullname"] = implode("->", $parent_href_array); $category_info_array["fullname"] = implode("->", $parent_array); } return $category_info_array; } function get_url_info($url_id) { global $link_id, $default_dbname, $directory_tablename; if(!$link_id) $link_id = db_connect($default_dbname); $query = "SELECT url_id, category_id, title, url, description,registerdate, date_format(registerdate, '%M, %e, %Y') as formatted_registerdate, hit, lastaccesstime, date_format(lastaccesstime, '%M, %e, %Y %r') as formatted_lastaccesstime, password, email, approved FROM $directory_tablename WHERE url_id = '$url_id'"; $result = mysql_query($query); if(!$result) echo sql_error(); return mysql_fetch_array($result); } function search_form($category_id) { global $root_category_id, $PHP_SELF; if(!isset($category_id)) $category_id = $root_category_id; ?> "> Search: ">Current Category ">All Categories OR AND $category_href_fullname ($num_child_str, $num_item_str) \n"; else echo " $category_href_fullname ($num_child_str) \n"; search_form($category_id); $query = "SELECT category, category_id FROM $category_tablename WHERE (length(category_id) = $category_depth * $category_id_length) AND category_id LIKE '$category_id%' ORDER BY category"; $result = mysql_query($query); if(!$result) echo sql_error(); if(mysql_num_rows($result) > 0) { ?> \n"; echo "\n"; echo "<\"$PHP_SELF?action=show_list> category_id=$my_category_id\"> $my_category ($num_child_str, $num_item_str)\n"; echo "\n"; if(!($i % 2)) echo "\n"; $i++; } if(!($i % 2)) { echo " \n" ; echo ""; } ?> $found_str - Keyword(s): $keywords \n"; if($total_num > 0) echo " Displaying page $page_num out of $last_page_num \n"; $query = "SELECT url_id, category_id, title, url, description, date_format(registerdate, '%M, %e, %Y') as formatted_registerdate, hit, date_format(lastaccesstime, '%M, %e, %Y %r') as formatted_lastaccesstime, hit FROM $directory_tablename WHERE $category_str AND approved = 1 $keyword_str ORDER BY registerdate DESC $limit_str"; $result = mysql_query($query); if(!$result) echo sql_error(); $i = 1; while($query_data = mysql_fetch_array($result)) { $url_id = $query_data["url_id"]; $formatted_registerdate = $query_data["formatted_registerdate"]; $formatted_lastaccesstime = $query_data["formatted_lastaccesstime"]; $url = "http
[PHP-DB] Re: Mysql not receiving the data
take a look at the sql insert sintaxe... it's supposed to be: INSERT INTO table VALUES (val1,val2,...,valn); all string and date values go between ' '...numeric values don't need them... here's an example: INSERT INTO table VALUES ('abc',500,'12-12-2003'); if your table has 5 fields but you don't want to insert values for them all then you must specify the fields that you want to insert: INSERT INTO table (field1,field2) VALUES (val1,val2); hope this helps. Rui Cunha Andrew Rothwell writes: Hi Larry, Thank you very much for the very quick response, I set my php.ini file (located /etc/php.ini ) for the register_globals = On (it was off by default) Now however I get an error Error adding entry: You have an error in your SQL syntax near 's spanish driver is found shot dead, Inspector Jacques Clouseau is the first off' at line 8 My Database is a movie database of my dvd's that I own (for insurance reasons) My addmovie.php is this mysql_connect("localhost","username","password"); mysql_select_db("movies"); $add = "INSERT INTO movies SET movie_name='$movie_name', genre='$genre', director='$director', star1='$star1', star2='$star2', star3='$star3', brief_synopsis='$brief_synopsis', imdb_link='$imdb_link'"; if (@mysql_query($add)) { echo("Your entry has been added. $movie_name"); } else { echo("Error adding entry: " . mysql_error() . ""); } ?> And the addmovie.htm page (atleast the form action is this) bordercolordark="#FF0033" bordercolorlight="#66"> Movie Name Andrew -Original Message- From: Larry E. Ullman [mailto:[EMAIL PROTECTED] Sent: Sunday, June 13, 2004 11:22 AM To: Andrew Rothwell Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Mysql not receiving the data Online I could see everything, and the pages gave the appearance of working, however when I went into the DB using PHPMYADMIN to check the status of the new data entered, all I found was blank rows ( for the new data since the rebuild, all the old data was there) There were the correct number of new rows for the amount of records that I had entered, which tells me (unless I am nistaken) that the PHP is talking to the DB, and is atleast sending a insert command, but the rest of the data is not getting in. - Without seeing any code whatsoever and since this worked before but no longer works on a new install, I can only assume that your code was written with the assumption that register_globals was turned on and it's not on in your current configuration. If that is the case, see the PHP manual or search the Web for the solution ($_POST, $_GET, etc.). Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] auto update mysql table with the current date & time
Hi if you change the field type to TIMESTAMP mysql will do it for you http://dev.mysql.com/doc/mysql/en/DATETIME.html Peter > -Original Message- > From: Gawie Marais [mailto:[EMAIL PROTECTED] > Sent: 14 June 2004 09:25 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] auto update mysql table with the current date & time > > > hi guys, > > me again ! i need to update a record in a mysql table. now i have > defined a > datetime field when a record is modified... i want to 'auto update' that > field whenever a record is modified... what would the php script be for > something like that... ? > > > thanx, > > gawie. > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > Email has been scanned for viruses and SPAM by Trader Mailmanager > www.trader.uk.com > > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: auto update mysql table with the current date & time
"Gawie Marais" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi guys, > > me again ! i need to update a record in a mysql table. now i have defined a > datetime field when a record is modified... i want to 'auto update' that > field whenever a record is modified... what would the php script be for > something like that... ? Hi Gawie, you have to use the timestamp column type for auto-updates. Set the default to NULL and it will be set/updated when you insert or update a record. See here: http://dev.mysql.com/doc/mysql/en/TIMESTAMP_pre-4.1.html Hope this helps. Torsten -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] auto update mysql table with the current date & time
hi guys, me again ! i need to update a record in a mysql table. now i have defined a datetime field when a record is modified... i want to 'auto update' that field whenever a record is modified... what would the php script be for something like that... ? thanx, gawie. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] get all records but limit to 6
thanx guys, it's working like a charm !! "Marcjon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think the problem is he wants to limit after he's sorted them. The > only way I know of to do that is to do the whole query without a limit > clause, then run through the results but only do whatever you have to do > with the first 6. > -- > Marcjon -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] get all records but limit to 6
"Marcjon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I think the problem is he wants to limit after he's sorted them. The > only way I know of to do that is to do the whole query without a limit > clause, then run through the results but only do whatever you have to do > with the first 6. No. The sorting is done BEFORE the limitation. So Sunmaia's query will work as required by Gawie. Regards, Torsten Roehr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php