Re: [PHP-DB] Selecting last row
Hi, if you're using an auto_increment field or another field which increases with every record (like date entered) you can use something like select * from table_name order by auto_field_name DESC limit 0,1 Hope this helps Dobromir Velev Web Developer http://www.websitepulse.com/ -- 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]
Re: [PHP-DB] Failed to query correctly.
Hi, I just looked over the code I sent and I saw that there is a bug there. Here's the corrected version. This one is tested and it works fine $query=SELECT * from $tbl; $result=mysql_db_query($db,$query) or mysql_die(); echo table; while ($line = mysql_fetch_assoc($result)) { if (!$firstrow){ echo tr; while(list($col_name, $col_value) = each($line)) { print \t\ttdp align=center$col_name/p/td\n; $firstrow.=\t\ttdp align=center$col_value/p/td\n; } echo /tr; echo tr$firstrow/tr; } else{ echo tr; while(list($col_name, $col_value) = each($line)) { print \t\ttdp align=center$col_value/p/td\n; } echo /tr; } } echo /table; Hope this helps Dobromir Velev Web Developer http://www.websitepulse.com/ -- 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]
Re: [PHP-DB] MySQL socket error
Hi, Check if your MySQL server is working properly - this error usually appears when the MySQL server is down. The other thing is to check whether the socket the MySQL server uses is /tmp/mysql.sock and if it is not modify the php configuration variable MYSQL_SOCKET Hope this helps Dobromir Velev Web Developer http://www.websitepulse.com/ -Original Message- From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, November 29, 2001 23:48 Subject: [PHP-DB] MySQL socket error Hi I'm having a really big problem at the moment (or at least my server provider is and it's gettting abit tiresome!) I've been using PHP/MySQL combo for a looong time, and never come across this error before, and I don't know exactly what is causing it. There's a new installation of php4.04 pl and MySQL 3-23-39 on red hat, but when I try and run my usual php_connect I get the following error: - Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in testfile.php on line 2 Anyone have any ideas what is causing this (or more to the point how to fix it - is it a configuration file issue, and if so which one?) Thanks Tom --part1_44.171de6dc.293805d8_boundary Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi I'm having a really big problem at the moment (or at least my server provider is and it's gettting abit tiresome!) I've been using PHP/MySQL combo for a looong time, and never come across this error before, and I don't know exactly what is causing it. There's a new installation of php4.04 pl and MySQL 3-23-39 on red hat, but when I try and run my usual php_connect I get the following error: - Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in testfile.php on line 2 Anyone have any ideas what is causing this (or more to the point how to fix it - is it a configuration file issue, and if so which one?) Thanks Tom (If you reply to me direct, please use [EMAIL PROTECTED] , not the borrowed AOL address that this has just been sent from!) -- 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]
Re: [PHP-DB] set primary key of a mysql-table automatically as value in other tables of the same db
Hi, First you insert the record in the main table, then using the mysql_insert_id() finction (Check www.php.net/mysql_insert_id for details) you retrieve the new auto_increment value and then you insert the records in the related tables. your script should look something like this: ? $res=mysql_query(insert into main (id,field_one,...) values (null,'$field_one',...),$db); $id=mysql_insert_id(): mysql_query(insert into table_one (id_main,table_one_field_one,...) values ($id,$table_one_field_one,...),$db); mysql_query(insert into table_six (id_main,table_six_field_one,...) values ($id,$table_six_field_one,...),$db); ? Regards Dobromir Velev Web Developer www.websitepulse.com -Original Message- From: es said [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Friday, November 30, 2001 12:55 Subject: [PHP-DB] set primary key of a mysql-table automatically as value in other tables of the same db how to set the primary key of a mysql-table automatically as value in other tables of the same db via php? hi there, as being a newbie in this list, i don't know if my problem already has being solved. so here it is: i created a database containing 6 tables: 'main' got the key 'id_main' (integer auto_increment), every other table got the field 'id_main'(integer) too, to connect all of them. so, if I enter a new set of data via a php-form, the value $id_main is automatically given by mysql. but how do I tell the program to enter the same value $id_main in all of the other tables, because the value is given in mysql and not via php...? (maybe it would be better to automatically get the id of the last set and add 1. if someone got a script for this, i would be happy, too!) hopefully i was able to explain my question properly and someone got an answer. have a nice day! thanx cornelia -- 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]
Re: [PHP-DB] date format question
Hi, You could try to change date(m) to date(n), and date(d) to date(j). It looks that sometimes mktime() doesn't remove the trailing zeroes and returns totally different dates. The other thing you could try is $date = date(F dS, Y g:i:s A, date(U)+18000); this one takes the number seconds of seconds between the Unix Epoch (January 1 1970) and the currend time and adds 5 hours (18000 seconds) Hope this helps Dobromir Velev -Original Message- From: Matt Nigh [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Date: Wednesday, November 28, 2001 03:49 Subject: [PHP-DB] date format question hi, i'm wondering if anyone could help me in formatting a date so it is 5 hours ahead of the server time. here's the code i'm using but it doesn't seem to work: $date = date(F dS, Y g:i:s A, mktime(date(g)+5,date(i),date(s),date(m),date(d),date(Y)) ); i've already looked in the manual and around the net for stuff, but wasn't able to find anything for what i needed. if anyone could help out, i'd appreciate it. thanks, Matt -- 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]
Re: [PHP-DB] ?? If Table Exists, Drop Table, then Create Table ??
Hi, All MySQL version higher than 3.22 support the following syntaxis DROP TABLE IF EXISTS tbl_name HTH Dobromir Velev -Original Message- From: MrBaseball34 [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, November 27, 2001 18:37 Subject: [PHP-DB] ?? If Table Exists, Drop Table, then Create Table ?? Table Creation Script from SQL Server... if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Orders]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[Orders] GO CREATE TABLE [dbo].[Orders] ( [OrderID] [int] IDENTITY (1, 1) NOT NULL, . . . . ); GO Is there anything like the first line from mySQL? I need to check if a table exists and drop it if it does so it can be recreated. I do not have access to any admin facilities on my host so I need to be able to do this in a script I can modify. -- 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]
Re: [PHP-DB] What's wrong?
Hi, the most probable reason is that the file you're reading from was saved in a different filesystem and the $info[2] has some newline characters at the end. You can use the trim() function to remove it. Than your expression will look something like this if(count($info) != 1 $folder == trim($info[2])) HTH Dobromir Velev -Original Message- From: Sergio Augusto Bitencourt Petrovcic [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, November 20, 2001 13:58 Subject: [PHP-DB] What's wrong? Ho there...I really wonder what's wrong with this script. The error is in this line below: if((count($info) != 1) ($folder == $info[2])) echo tabletrtda href= . $info[1] . . $info[0] . /abr/td/tr/table; The condition ($folder == $info[2]) is not working! I hope you can help me! Here's the code: ?php $link_name = Tudo sobre automação; $link_address = http://www.automacao.eng.br;; $link_folder = faculdade; $file = teste.txt; function write($file,$link_name,$link_address,$link_folder) { $file=fopen($file,w); fwrite($file,$link_name|$link_address|$link_folder\n); fclose($file); } function read($file,$folder) { $file=fopen($file,r); while (!feof ($file)) { $buffer = fgets($file,1024); $info = explode(|,$buffer); if((count($info) != 1) ($folder == $info[2])) echo tabletrtda href= . $info[1] . . $info[0] . /abr/td/tr/table; } fclose($file); } write($file,$link_name,$link_address,$link_folder); read($file,faculdade); ? Thanks! -- 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]
Re: [PHP-DB] Query help
Hi, I haven't seen the previous posts so I'm not sure want you want to do, but it looks like that you need to specify a join condition. If freerooms.room and booking.room are the corresponding fields from your table the query should look something like this SELECT count(freerooms.room), WEEK(MAX(booking.date),1), WEEK(MIN(booking.date),1) as total FROM freerooms LEFT JOIN booking ON freerooms.room=booking.room USING(room); or SELECT count(f.room),WEEK(MAX(b.date),1), WEEK(MIN(b.date),1) FROM freerooms f, booking b WHERE f.room=b.room Hope this helps Dobromir Velev -Original Message- From: Matt Williams [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Monday, November 19, 2001 10:26 Subject: RE: [PHP-DB] Query help This doesn't work either. SELECT count(freerooms.room), WEEK(MAX(booking.date),1), WEEK(MIN(booking.date),1) as total FROM freerooms LEFT JOIN booking USING(room); All good so far now if I run this SELECT count(f.room),WEEK(MAX(b.date),1), WEEK(MIN(b.date),1) FROM freero oms f, booking b; -+---+-+-+ | count(f.room) | WEEK(MAX(b.date),1) | WEEK(MIN(b.date),1) | +---+-+-+ | 24817 | 48 | 40 | +---+-+-+ What I have found is freerooms.room has 83 rows and booking has 299. The value returned for count(f.room) is these two figures multiplied.??? Why would it do this? And how can I get it to return the real value only Regards M: -- 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]
Re: [PHP-DB] How to write errorhandling??
Hi, I see that everybody is looking for the error in the header function - but the error actually is that Luditus is trying to use mail on a Windows box with no SMTP server on it. It is possible to suppress the mail function output using @mail, but it won't fix the problem - if you want to use mail function on a WIN machine you'll need a sendmail like program and you will have to adjust the sendmail_path variable in your PHP configuration. HTH Dobromir Velev -Original Message- From: Luditus [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Sunday, October 21, 2001 1:41 PM Subject: [PHP-DB] How to write errorhandling?? Hi Fokes, I would like to send an mail via the mail function. If the mail failes I would like to redirect to an errorpage. Currently my code looks like this: if ( mail($email,$subject_confirm_account, $message_confirm_account, $from_confirm_account) ){ HEADER(Location:index.php?fuseaction=txtmsg=registered); file://success } else{ HEADER(Location:index.php?fuseaction=txtmsg=mailproblem); // mail could not been sent }; Unfortunatelly I get an erromessage like that: Warning: Failed to Connect in e:\projects\globosapiens\07_production\actual\account\include\user.php on line 256 Warning: Cannot add header information - headers already sent by (output started at e:\projects\globosapiens\07_production\actual\account\include\user.php:256) in e:\projects\globosapiens\07_production\actual\account\include\user.php on line 260 Where is the problem??? I can't see it. Maybe one of you guys could help me out. Thanx in advance, Luditus -- 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]
Re: [PHP-DB] How to write errorhandling??
Hi, I never said it is impossible to use mail() on a WIN machine - it just needs some additional adjustments of the php configuration file. For those who need more information on the topic check the user contributed notes at http://www.php.net/manual/en/ref.mail.php Regards Dobromir Velev -Original Message- From: DL Neil [EMAIL PROTECTED] To: Dobromir Velev [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Monday, October 22, 2001 2:29 PM Subject: Re: [PHP-DB] How to write errorhandling?? Luditus/Dobromir, It IS possible to run the mail function on a Win machine - I had a Win2000/IIS(with its own SMTP stub) box running PHP mail happily. Also it is possible to have a Win-with-no-local-SMTP configuration. I have re-jigged my WinNT portable to run the same PHP/Apache script connecting directly to my ISP's SMTP server (in part using the path var mentioned). I haven't tried to combine email with 'headers' though! ...if that's the problem... =dn Hi, I see that everybody is looking for the error in the header function - but the error actually is that Luditus is trying to use mail on a Windows box with no SMTP server on it. It is possible to suppress the mail function output using @mail, but it won't fix the problem - if you want to use mail function on a WIN machine you'll need a sendmail like program and you will have to adjust the sendmail_path variable in your PHP configuration. Hi Fokes, I would like to send an mail via the mail function. If the mail failes I would like to redirect to an errorpage. Currently my code looks like this: if ( mail($email,$subject_confirm_account, $message_confirm_account, $from_confirm_account) ){ HEADER(Location:index.php?fuseaction=txtmsg=registered); file://success } else{ HEADER(Location:index.php?fuseaction=txtmsg=mailproblem); // mail could not been sent }; Unfortunatelly I get an erromessage like that: Warning: Failed to Connect in e:\projects\globosapiens\07_production\actual\account\include\user.php on line 256 Warning: Cannot add header information - headers already sent by (output started at e:\projects\globosapiens\07_production\actual\account\include\user.php:256) in e:\projects\globosapiens\07_production\actual\account\include\user.php on line 260 Where is the problem??? I can't see it. -- 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]
Re: [PHP-DB] Sessions and Frames
Hi, Every different page in a framset is loaded separatly so the only thing you should be aware of is not to output anything before the session stuff. Also you can use the output control functions lie ob_start - check the PHP manual for more info. HTH Dobromir Velev -Original Message- From: TJayBelt [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, October 18, 2001 8:28 AM Subject: [PHP-DB] Sessions and Frames I have a site that is successfully using sessions and authentication. However, I am working on another site, and it uses Frames. The first site does not use frames, so including the unit that has the session stuff first works. But on the frames site, it gives the following error : 'Cannot add header information - headers already sent by ' I know that this is when something is trying to print before the session is started. I just don't know how to accomplish this if the page I am loading is inside a frame... so by the time the session stuff starts, html is already output to the browser. thanks for any help you can give. -- 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]
Re: [PHP-DB] Update Query?
Hi, The query code seems fine to me - did you try to otput $query to see if all the variables you are using are OK. May be $order,$stationid or $orderNewsID is misspeled or is not set properly. HTH Dobromir -Original Message- From: Jay Paulson [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, October 02, 2001 2:22 AM Subject: [PHP-DB] Update Query? Hello- I'm trying to run an update query in an application I'm making. I keep getting a MySQL error however when I try and print out the mysql_error() nothing is returned. I run the same query in phpMyAdmin and the query runs fine. Below is the update query I'm running and the php code that I'm using to build it. Any suggestions? update news set newsOrder=2 where station_id=5 and id=3 $query = update news set newsOrder=.$order. where station_id=$stationid and id=.$orderNewsID; thanks, jay -- 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]
Re: [PHP-DB] Yes or No
Hi, MySQL doesn't support this kind of fields - if you want to have a field that have only two values like 0/1 you should use char(1) or enum(0,1). Dobromir Velev -Original Message- From: Bartek Pawlik [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED]; [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, October 02, 2001 12:57 PM Subject: Odp: [PHP-DB] Yes or No Use boolean field, it takes only values Yes/No, 0/1, True/False. Bartek Pawlik Poland - Original Message - From: Jordan Elver [EMAIL PROTECTED] To: MySQL Mailing List [EMAIL PROTECTED]; PHP DB Mailing List [EMAIL PROTECTED] Sent: Tuesday, October 02, 2001 11:23 AM Subject: [PHP-DB] Yes or No Hi, If I wanted to define a table to have a cloumn which is either yes or no for example. Would it be better to use a single char (0 or 1), or can I use an enum (I find them more friendly ;)). Could you offer some advice? Thanks, Jord -- Jordan Elver Web Developer The InternetOne UK Ltd -- 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] -- Zagraj z finalistkami Miss Polonia [ http://miss.onet.pl/start.html ] -- 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]
Re: [PHP-DB] HTML or PHP?
Hi, Just set the width of the cell the URL is placed in. Something like trtd width='300'$url/tdtd width='300'.../td/tr HTH Dobromir Velev -Original Message- From: Jason Caldwell [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, October 03, 2001 2:20 AM Subject: [PHP-DB] HTML or PHP? I have a problem that seems like it should be a snap to fix, but leaves me feeling frustrated to no end... I have a table (HTML) -- 2 Columns. In the right-hand column I store a URL (ie. http://someonesdomainname.com/path/anotherpath/file.html) The problem is -- when I pull the URL in -- it *pushes* my columns around and expands my table beyond the page -- I have my table hard set at 600 pixels (not 100%) -- How can I force the URL (or any text for that matter that doesn't have spaces in it) -- to *wrap*?? Can I do this with HTML (I hope) or do I need to write some PHP code to force break the string into workable sections? Thanks. [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]
Re: [PHP-DB] eregi and ereg??
Hi, You cannot put multiple variables in ereg(). This is taken from http://www.php.net/manual/en/function.ereg.php i think it will explain it better If matches are found for parenthesized substrings of pattern and the function is called with the third argument regs, the matches will be stored in the elements of the array regs. $regs[1] will contain the substring which starts at the first left parenthesis; $regs[2] will contain the substring starting at the second, and so on. $regs[0] will contain a copy of string. If ereg() finds any matches at all, $regs will be filled with exactly ten elements, even though more or fewer than ten parenthesized substrings may actually have matched. This has no effect on ereg()'s ability to match more substrings. If no matches are found, $regs will not be altered by ereg(). There are some code snippets that ilustrate the use of the $regs array. HTH Dobromir Velev -Original Message- From: Jason Caldwell [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Friday, September 14, 2001 8:15 AM Subject: [PHP-DB] eregi and ereg?? www.php.net shows the proper format for EREG and EREGI is: int ereg (string pattern, string string [, array regs]) My question is this; I want to be able to compare 2 or more strings to the EREG(I) STRING PATTERN... without having to create two separate EREG(I) IF...THEN statements... If I understand the format as displayed above, then I should be able to put multiple variables in the EREG(I) expression... like so; if(eregi(x, $string1 $string2 $string3, $regs) Is this correct? Or, do I have to specify an IF...THEN type of statement for each $STRING ?? Thanks Jason [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]
Re: [PHP-DB] moving uploaded files
Hi, PHP has its own filesystem functions which you can use. If you want to move a file from one location to another you could use something like this ? copy($old_file,$new_file); unlink($old_file); ? The $old_file and the $new_file variables should contain the absolute path e.g. /home/user/filename.txt Check http://www.php.net/manual/en/ref.filesystem.php for a more detailed explanation of the filesystem functions. HTH Dobromir Velev -Original Message- From: Jon Mormino [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, September 13, 2001 11:10 PM Subject: [PHP-DB] moving uploaded files Does anyone have a solution for the following problem. I use dbwired.com for hosting (great service). They do not, however, for obviously reasons allow the system() command from a php script. So, when I switched to this server I had to switch from a system(mv file1 file2); command to a move_uploaded_file(path1,path2); command which is fine...for uploading. But, once a file is uploaded I can't figure out a way to move or delete it as it is no longer considered an uploaded file and hence move_uploaded_file() fails. Does anyone know a way around this? Thanks. -Jon Mormino -- 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]
Re: [PHP-DB] Not so relative but important...
Hi, try ? $fp = fopen(file.doc,r); Header(Content-Type: application/x-octet-stream); Header( Content-Disposition: attachment; filename=file.doc); passthru($fp); ? HTH Dobromir Velev -Original Message- From: Koutsogiannopoulos Karolos [EMAIL PROTECTED] To: 'Php-Db (E-mail) [EMAIL PROTECTED] Date: Friday, September 14, 2001 1:44 PM Subject: [PHP-DB] Not so relative but important... Hello everyone... This is not a very relative question to DB and php but would mean a lot if someone helped me out.. It involves html headers... What i want to do is when i have a pdf or doc file ... using a special header, when clicking the file the page to download the file and not opening it as usual.. Is tha possible??? Can someone help me out? -- 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]
Re: [PHP-DB] array in db field - actual array
Hi, I think you can use the eval() function to execute the stored info. The code will look something like this $res=mysql_query(...) eval($row_from_query); If you want to change the name of the array you could use eval(str_replace($array,$newarray,$row_from_query)); HTH Dobromir Velev -Original Message- From: brendan [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, September 13, 2001 2:20 PM Subject: [PHP-DB] array in db field - actual array hi, i am currently scouring the web for a solution to this but thought i would try here as well .. i have a text field in a mysql database the textfield contains an array written out as // $array[0][1]=one; $array[0][2]=two; $array[0][3]=thre; $array[1][1]=four; $array[2][1]=five; // now i need to extract this from the db .. simple and use it as an array for a function .. not as simple as i thought it would be ie $newarray =mysqlquery('etc','etc','etc') and $newarray should be $newarray[0][1]=one; $newarray[0][2]=two; $newarray[0][3]=thre; $newarray[1][1]=four; $newarray[2][1]=five; elp? cheers brendan -- 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]
Re: [PHP-DB] SQL problem
Hi, Are there any error messages? Just a guess - may be this will work Select $tbl_virtual.thumb1,$tbl_descriptions.short_desc FROM $tbl_virtual left join $tbl_descriptions on $tbl_virtual.id_property=$tbl_descriptions.id_property WHERE $tbl_virtual.id_property=$link Dobromir Velev -Original Message- From: Robert Vukovic [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Friday, August 31, 2001 7:34 AM Subject: RE: [PHP-DB] SQL problem Table was created with this CREATE TABLE `descriptions` ( `id_property` bigint(20) NOT NULL default '0', `short_desc` varchar(255) default NULL, `long_desc` text, KEY `id_property`(`id_property`), PRIMARY KEY (`id_property`), UNIQUE KEY `id_property_2`(`id_property`) ) TYPE=MyISAM COMMENT=''; and this is query: $res1=mysql_query(SELECT $tbl_virtual.thumb1,$tbl_descriptions.short_desc FROM $tbl_virtual,$tbl_descriptions WHERE $tbl_virtual.id_property=$link and $tbl_descriptions.id_property=$link) virtual is another table with picture names. This query work at my home but not on real site. What is a problem. ? I forgot to say that PHP is 4.04 and I am using MySQL -- 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]
Re: [PHP-DB] Selection an id from a table where it doesn't exisit in another
Hi, I think this should do the job SELECT words.id FROM words left join searchwords on words.id = searchwords.word_id where searchwords.word_id is Null; Let me know if it is OK. Dobromir Velev -Original Message- From: Scott Mebberson [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, August 30, 2001 4:17 AM Subject: [PHP-DB] Selection an id from a table where it doesn't exisit in another Hi Guys, I have two tables, words and searchwords. words contains a list of words with an id number next to them and searchwords contains a page id with a word id (from the words table). I want to select all of the id's from the words table which does not exist in the word_id feild in the searchwords table. Make sense, it is for searching? Let me know if it doesn't. This is the SQL query I am running on MySQL (3.22) - SELECT id FROM words, searchwords WHERE words.id != searchwords.word_id; It isn't working. All it does it return a list of results which are totally incorrect. Thanks Scott. -- 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]
Re: [PHP-DB] Finding NoMatches in MySQL
Hi, I think this query should do the job SELECT jobs.uid FROM jobs LEFT JOIN employers ON jobs.id1 = employers.uid WHERE employers.uid is Null Dobromir Velev -Original Message- From: Dave Watkinson [EMAIL PROTECTED] To: PHP-MySQL List [EMAIL PROTECTED] Date: Monday, July 30, 2001 12:56 AM Subject: [PHP-DB] Finding NoMatches in MySQL Hi all During the process of importing a lot of Oracle data into MySQL, I have two tables that are giving me a bit of a headache. One is a list of jobs and the other is a list of employers. There's now a unique id for each table, and the job table also has a column called id1, which *should* correspond to employers.uid. With me so far? Well, the problem is that there were loads of duplications in the employers table, and after deleting the duplicates some of the jobs.id1 records now point to non-existing records. How do I do a query that does something like this... select jobs.uid from jobs where jobs.id1 not in employers.uid ??? many thanks in advance! Dave -- 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]
Re: [PHP-DB] Question on how to test a value
Hi, even if there was no data in the price field when the form was submited the $price variable exists and isset($price) returns true. May be you could try !empty($price) instead of isset($price) - Something like. $query7 = !empty($price) ? INSERT INTO price (itemid, price) VALUES ($itemid, '$price') : 0; $result7 = @pg_Exec($connection, $query7 ); Then when the price field is empty your script will not insert anything into the database. You can also modify your select query not to show records without price select * from price where itemid=50 and price is not Null and price; Hope this will help Dobromir Velev -Original Message- From: Lara J. Fabans [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, July 25, 2001 7:52 PM Subject: [PHP-DB] Question on how to test a value Hi, friends, Here is how I'm putting the information into the database: $query7 = isset($price) ? INSERT INTO price (itemid, price) VALUES ($itemid, '$price') : 0; $result7 = @pg_Exec($connection, $query7 ); I'm having difficulties with my test in display. I've tried isset and == 'NULL' and == '0' as such: if ($values2 == 'NULL') { print trtd class=\display\nbsp;/td/tr; } else { print trtd class=\display\US$ $values2-price/td/tr/table/td; } and if (isset($values2)) { print trtd class=\display\US$ $values2-price/td/tr/table/td; } else { print trtd class=\display\nbsp;/td/tr; } However, in both cases, if the price doesn't exist in the database, the US$ still shows up in the display. db= select * from price where itemid=50; priceid | itemid | price -++--- 48 | 50 | (1 row) I was surprised that the insert put something into the database at all. I could use some advice. I cleaned up the database to remove all the lines where price wasn't set. Why is it creating a table row? If the insert form is passing in where they didn't set the price, wouldn't that get picked up by the isset? And if there isn't a row in the database, wouldn't testing isset of the result of the query be sufficient, or should I do a test on $values2-price instead? I've tried lots of things and nothing seems to be doing the right behavior. So thanks! Lara -- 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]
Re: [PHP-DB] draw graph
Check http://www.phplot.com I think it could be helpful Dobromir Velev -Original Message- From: Sommai Fongnamthip [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, July 25, 2001 11:35 AM Subject: [PHP-DB] draw graph Dear, How could I draw graph with gd by using PHP code with custom log scale? Sommai Fongnamthip -- 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]
Re: [PHP-DB] PHP - MySQL
Hi, you could point the form to submit itself to the same page, log the click and then redirect to the next page with heade(Location: next_page.php); Hope this helps Dobromir Velev -Original Message- From: Pranot Kokate [EMAIL PROTECTED] To: PHP-DB list [EMAIL PROTECTED] Date: Wednesday, July 25, 2001 11:56 AM Subject: [PHP-DB] PHP - MySQL Dear friends, how can i monitor/count how many times a button is clicked. The code should not be on the page which comes after clicking, but on the same page where the button is. This is the need pls help regards, pranot -- 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]
Re: [PHP-DB] Allowing refresh without form processing?
Hi, Name your form submit button somehow, for example input type=Submit name=my_submit_button value=Submit then when the page is refresh check if there is a variable named $my_submit_button. If there is not than the page is refreshed using the refresh button or the form was submitted with th Enter key. You will process the form only when there is variable $my_submit_button which means that someone has pressed the submit button. Dobromir Velev -Original Message- From: John Pickett [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, July 25, 2001 4:59 PM Subject: [PHP-DB] Allowing refresh without form processing? Hey, I have a page where I'd like to allow the client to use their refresh button. The only problem with this is, when they submit a form that's on the page, it is parsed by the same page. So if they hit refresh, the same information will be submitted twice (or more). How can I clear out any knowledge that a form was submitted? I've tried adding unset ($HTTP_POST_VARS); to the bottom of the page but that didn't do anything for it... Any other ideas? BTW, I'm asking this because the form uses a db to process and I'm unsure if that may be the issue or not... My 2 ? John Pickett http://www.bvstudios.com/ Co-Author: Inside Dreamweaver 4 http://www.amazon.com/exec/obidos/ASIN/0735710848/xtremist -- 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]
Re: [PHP-DB] line breaks in mySQL text fields
Hi, You could put \n where you want the new line. Than if you want to output the text field in HTML you could use nl2br() to replace the new line characters with br For example take a look at this INSERT query: $sql= INSERT INTO table_name (text_field,...other_fields) VALUES ('first row\nsecond row',...other_values); Hope this helps Dobromir Velev -Original Message- From: kmurrah [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Monday, July 23, 2001 9:15 PM Subject: [PHP-DB] line breaks in mySQL text fields How do I add new line characters to a text field in mySQL ? i.e. i need to manually insert returns into my text ... thanks in advance, KennM -- 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]
Re: [PHP-DB] Protecting database password
Hi, I suggest you use a .php file to declare your database variables and include it everywhere you need it. Even if someone guesses the name of this file when he tries to open it, nothing will be outputed to the screen. an example file is ? $dbname=name; $dbuser=user; $dbpass=pass; ? Than you'll have to set the permissions of this file in a way that noone (except you and the process that runs the php) with access to the server can read this file. Hope this helps Dobromir Velev -Original Message- From: Marco Draijer [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, July 18, 2001 10:42 AM Subject: [PHP-DB] Protecting database password For a PHP-application on Windows NT, I am using an Oracle database and the database-interface db_oci8.inc (a PHP-class, downloaded from the net). To be able to make the connection to the database, the class has to know the databasename, username, and password. At the moment, it is hardcoded in the include-file. This file can be downloaded by anyone who knows its exact name and location (which is not hard, of course). I want to prevent this. I have tried some things with permissions, but I could not find a solution there. A known solution on Windows-platforms is, to put the names password in the registry of the server, but I don't know how I can read data from the registry in PHP. Another solution is to use environment variables. I know how to read them: the documentation says that getenv() gives the environment of the client, but that is not true, at least on NT it gives the environment of the server. But then again: of which user is that environment and won't it be easy to read that environment over the internet? Can anyone give me advice on this? Furthermore I will be setting up a similar construction (PHP + password protected database) on a Linux machine. So I am also interested in Unix-only solutions. Thanks in advance, Marco Draijer -- *** * This message contains information that may be privileged or confidential and is the property of the Cap Gemini Ernst Young Group. It is only intended for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. *** * -- 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]
Re: [PHP-DB] Need syntax for conditional in recordset loop
Hi, You could use something like #start do { echo tr; $fields=odbc_num_fields($data2); for($i=3 ; $i=$fields ; $i++) echo td nowrap; if (odbc_result($data2,$i) = 'SOX') echo a href='sox_page_url'.odbc_result($data2,$i)./a; else echo odbc_result($data2,$i); echo /td/tr\n; } while(odbc_fetch_row($data2)); echo /table; #end The idea is to output one thing when the result matches your criteria and another when it doesn't. Hope this helps Dobromir Velev -Original Message- From: John A DAVIS [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, July 17, 2001 2:39 AM Subject: [PHP-DB] Need syntax for conditional in recordset loop How would I code IF .odbc_result($data2,$i) = 'SOX' THEN make it a link? By link I mean that I want the word SOX highlited in blue and underlined and referencing a webpage that explains SOX verbosefully. Don't know PHP IF THEN syntax too well. /* fill table with data */ do { echo tr; $fields=odbc_num_fields($data2); for($i=3 ; $i=$fields ; $i++) echo td nowrap.odbc_result($data2,$i)./td; echo /tr\n; } while(odbc_fetch_row($data2)); echo /table; John A. Davis Information Systems Specialist OHD DWP State of Oregon -- 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]
Re: [PHP-DB] Chose ID from Table ?
Hi, If you're using MySQL you could try with mysql_insert_id() http://www.php.net/manual/en/function.mysql-insert-id.php Dobromir Velev -Original Message- From: Andreas Iwanowski [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Friday, July 13, 2001 2:12 PM Subject: [PHP-DB] Chose ID from Table ? Hello How can i do this here: I have a script, where i insert informations into a table. I now want now to read out the ID those informations got. Hot to do that ? -- mfg, andy - In Memoriam - Jaques www.amdclan.de/jaques -- -- 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]
Re: [PHP-DB] Left Join is producing duplicate results - MySQL relational tables
Hi, Did you try to use something like this. mysql_query(SELECT DISTINCT WLPbib.bibID, WLPbib.title, WLPbib.publisher, WLPbib.publicationDate, WLPaddress.city, WLPaddress.state, WLPprofile.firstName, WLPprofile.lastName, WLPprofile.organization, WLPcountry.languageName FROM ((WLPbib LEFT JOIN WLPprofile ON WLPprofile.profileID = WLPbib.profileID) LEFT JOIN WLPaddress ON WLPaddress.publisherID = WLPbib.publisherID) LEFT JOIN WLPcountry ON WLPcountry.countryID = WLPaddress.countryID); The other thing that may help is to rearange the order of the tables in the FROM clause. Please check if some of the joins return more than one result - if you have more than one address for a publisher the query will return one row for every address. Hope this helps Dobromir Velev -Original Message- From: Mike Gifford [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 12, 2001 4:31 AM Subject: [PHP-DB] Left Join is producing duplicate results - MySQL relational tables Hello, I posted this to the general list this morning got a couple of good leads, but they weren't able to actually fix the problem, so I'm posting here to the db list. I'm making some headway on joining three MySQL tables. However, when I run this query: mysql_query(SELECT WLPbib.bibID, WLPbib.title, WLPbib.publisher, WLPbib.publicationDate, WLPaddress.city, WLPaddress.state, WLPprofile.firstName, WLPprofile.lastName, WLPprofile.organization, WLPcountry.languageName FROM WLPbib LEFT JOIN WLPprofile ON WLPprofile.profileID = WLPbib.profileID LEFT JOIN WLPaddress ON WLPaddress.publisherID = WLPbib.publisherID LEFT JOIN WLPcountry ON WLPcountry.countryID = WLPaddress.countryID); I now get results in triplicate. ie. I'm getting three copies of the same title, firstName, organization, etc I somehow suspected that this should be the result with LEFT JOIN, but I'm not sure how to return a query without duplication. This is far better than what I had this morning (which was no response from the server). Thanks. I'm new to joining tables... Someone wrote back suggesting that SELECT DISTINCT could be used to to the job. Another person suggested that using UNIQUE(profileID) would make it look nicer. I wasn't sure how to use UNIQUE with the last JOIN as it isn't directly linked to WLPbib.. Any suggestions would be useful. Mike -- Mike Gifford, OpenConcept Consulting, http://openconcept.ca Offering everything your organization needs for an effective web site. Abolish Nuclear Weapons Now!: http://pgs.ca/petition/ It is a miracle that curiosity survives formal education. - A Einstein -- 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]
Re: [PHP-DB] Paging help needed :-(
Hi, First you'll have to modify your query to show only ten rows. $sql = SELECT id, email, name, subject, url, image2, comments, dat FROM users ORDER BY id DESC LIMIT $start,10; The $start variable shows the number of the first row to show The links for the previous and next page will be something like this ? if ($start=10)echo a href='your_page.php3?.($start-10).'Previous/a; echo a href='your_page.php3?.($start+10).'Next/a; ? You can play around with this code to allow the users to go directly to a specific page, not to show the Next link when there are no more records to show, allow users to define how many records to show in a page and etc. Dobromir Velev -Original Message- From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 12, 2001 7:53 AM Subject: [PHP-DB] Paging help needed :-( Hi there Everyone, I currently have a dedicated Apache server with PHP 4.06, MySQL etc .. installed and running fine. Below is alittle peice of code that I would love an answer to: ?php $connection = mysql_connect(Localhost,username!!!,password!!!) or die(Couldn't make a connection.); $db = mysql_select_db(planet, $connection) or die(Couldn't select database.); $sql = SELECT id, email, name, subject, url, image2, comments, dat FROM users ORDER BY id DESC; $sql_result = mysql_query($sql,$connection) or die(Couldn't execute query.); ? ? while ($row = mysql_fetch_array($sql_result)) { $email = $row[email]; $name = $row[name]; $subject = $row[subject]; $url = $row[url]; $image2 = $row[image2]; $comments = $row[comments]; $dat = $row[dat]; $comments=nl2br($comments); include(censorguestbook.php); $ip = getenv (REMOTE_ADDR); ? then all the HTML and display bits (Example at www.planetoxygene.com in the guestbook). ? } mysql_free_result($sql_result); mysql_close($connection); ? Now my question is, how do I do paging in PHP? I need to display 10 entries per page, and be able to go back and forth with them. I'm relatively new to PHP so I would be really grateful for any advice. Thanks everyone, I appreciate it. Chris Payne www.planetoxygene.com -- 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]
Re: [PHP-DB] PHP4 + interbase = bug?
Hi, What version of php4 you're running and on what OS. I had this problem too but when I switched to php 4.06 on win2000 the interbase dll worked just fine. Dobromir Velev -Original Message- From: Wagner R. Landgraf [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, July 10, 2001 11:53 PM Subject: [PHP-DB] PHP4 + interbase = bug? Hello, I've used PHP4 + Interbase and I got a PHP Program executed an ilegal operation bla bla bla bla. in a very very simple php script. Then I switched back to PHP3 and everything is fine (well, everything for this only little script I've tested). Is this know? Is PHP4 + Interbase buggy? What about PHP3? Is it ok with Interbase? Thank you all Wagner R. Landgraf Automa Consultoria Informática Ltda. [EMAIL PROTECTED] mailto:[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]
Re: [PHP-DB] losing data from a mysql database field
Hi, did you try to use quotes around the field value input type=text name=your_text value=value or echo input type='text' name='field_name' value='$field_value'; Dobromir Velev -Original Message- From: Geoffrey Makstutis [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Tuesday, July 10, 2001 9:03 PM Subject: [PHP-DB] losing data from a mysql database field Hi, I'm having an odd occurrence using mysql. If I insert into a varchar field with information like This is the information, it works fine and I can retreive and display the data using a normal 'print' or 'echo' statement. However, if I try to display the data in a form field (so that I can edit the data) I only get This (ie. I am losing everything after the first whitespace character). Is there anything that anyone could suggest that would solve this problem? Thanks. Geoffrey -- 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]
Re: [PHP-DB] how to get ERROR message
Hi, dud you try to use something like this $result=mssql_query(exec x) or die(mssql_get_last_message()); instead of $result=mssql_query(exec x) or die(query failed); Removing the or die part must display an error message too, but it won't end the script execution. Dobromir Velev -Original Message- From: jong jong [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, July 05, 2001 7:38 PM Subject: [PHP-DB] how to get ERROR message Hi, How can I see the error message from browser? My code is like this: htmlbody ? $conn=mssql_connect(xxx,,); mssql_select_db(xxx,$conn); $result=mssql_query(exec x) or die(query failed); mssql_free_result($result); ? /body/html I got query failed on the browser screen and nothing else. Here is some value I got from phpinfo(): Configuration PHP Core Directive Local value Master value display_errors On On display_startup_errors Off Off doc_root no value no value enable_dlOn On error_append_string Off Off error_log no value no value error_prepend_string OffOff error_reporting 2039 2039 Are they enough to display the error messages? Please help! I really do need to trace the errors. Thanks, jongjong __ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ -- 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]
Re: [PHP-DB] Authomatic Sorting
When you delete a record it doesn't affect the other ones, so if you want to change the other ones you have to update them too. For this purpose I use the following SQL command after deleting a row: UPDATE table SET id_field=id_field-1 where id_fielddeleted_ID_value I hope this will help Dobromir Velev -Original Message- From: Wilmar Pérez [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Date: Wednesday, July 04, 2001 11:45 PM Subject: [PHP-DB] Authomatic Sorting Hello guys I have the following two problems: I've got a table with an autoincrement field which is the registry's ID, everything goes well until I delete any registry. MySQL doesn't re-sorts the information. That is, I have the following: 001 user1 002 user2 003 user3 If I delete user2, I would like to have something as shown next: 001 user1 002 user3 But instead I end up with the following: 001 user1 003 user3 Any idea or comment? --- Wilmar Pérez IT Manager - Central Library University of Antioquia Medellín - Colombia tel: ++57(4)2105145 --- -- 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]
Re: [PHP-DB] adding Carrol O'Conner in a form
Hi, The slash is added because you have magic_quotes_gpc() turned on in your php configuration file - when magic_quotes are on, all ' (single-quote), (double quote), \ (backslash) and NUL's are escaped with a backslash automatically. You can turn this configuration directive off or you can use stripslahes() to remove the slashes. Dobromir Velev -Original Message- From: Ken Sommers [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Sunday, July 01, 2001 7:22 AM Subject: [PHP-DB] adding Carrol O'Conner in a form HI, IF i add my name as Carol O'Conner in a form and Echo (PHP 4.06 on win 95) it back I see Carol O\'Conner If I pass that name along to another page I'll see it as: Carol O\\\'Conner Even if I use : ?php echo(htmlspecialchars ($name, ENT_QUOTES)); ? IF I enter my name as:Carol O'Conner died I'll see it echoed as Carol O\'Conner died so I am thrilled that the came back and was displayed as it was typed in by the user but how do I get rid of that pesky slash \ ? so I can echo exactly what the user typed in? I am already using: ?php echo(htmlspecialchars ($name, ENT_QUOTES)); ? Thanks for the help, ken -- 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]
Re: [PHP-DB] define variable by querying MySQL
Hi, I'm not sure what were you trying to do but there are some very obvious errors 1. You cannot embed one php openning tag (?) in another 2. mysql_numrows() is not a valid mysql function - may be you were trying to use mysql_num_rows() If you are trying to put all fields my_name into the $WELCOME variable (I can't think of a reason to do this) and then echo it may be you could use this code #start code ? $link = mysql_connect(localhost,username,password) or die (Could not connect to MySQL!); mysql_select_db(database,$link); $result = mysql_query(select * from table_name); while ($row=mysql_fetch_array($result)){ $WELCOME.=$row[my_name]; } echo $WELCOME; ? #end code Dobromir Velev -Original Message- From: Matt Nigh [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Monday, July 02, 2001 1:01 AM Subject: [PHP-DB] define variable by querying MySQL hello list. i have a problem that is relatively simple, but I can't seem to figure it out. is there any way to define a variable by querying a MySQL database? here's an example of code I tried using: ? $WELCOME = echo ?php $link = mysql_connect(localhost,username,password); if(!$link) die (Could not connect to MySQL!); mysql_select_db(database,$link); $result = mysql_query(select * from table_name); $num=mysql_numrows($result); for($x=0;$x$num;$x++) { $row=mysql_fetch_object($result); print $row-my_name; } mysql_close($link); ? ; ; ? ? echo($WELCOME); ? it kept coming up with the following : Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\apache group\apache\htdocs\page.php on line 5 i can't figure out what to do, so if anyone can assist me, i'd be greatful. I have a feeling it's something with some quotes but i can't figure out which ones. Thanks a lot, Matt Nigh [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]
Re: [PHP-DB] MySQL Error???
Hi, This error occurs when your auto_increment index field is of type TINYINT. This field type can accept values form -128 to 127 so you cannot add records with index value greater than 127. I recommend you change it to INT(11) UNSIGNED which can accept values from 0 to 4294967295. If you expect to have more records you may consider using BIGINT type For more info check the MySQL language reference. Dobromir Velev -Original Message- From: Brian Grayless [EMAIL PROTECTED] To: PHP DB list (E-mail) [EMAIL PROTECTED] Date: Thursday, June 28, 2001 9:29 AM Subject: [PHP-DB] MySQL Error??? Is anyone familiar with this MySQL error? 1062: Duplicate entry '127' for key 1 I wrote a great bookmark management program that works fine, but everytime I insert bookmarks, I insert somewhere over 120 and I start getting this error, and it won't add them anymore. Any suggestions??? Thanks, B R I A N G R A Y L E S S Web Administrator Premier Resorts www.premier-resorts.com P: 435-655-4812 F: 413-618-1518 -- 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]
Re: [PHP-DB] Modify Query, or sift through results?
Hi, you could use the FIND_IN_SET(str,strlist) function which returns a value 1 to N if the string str is in the list strlist consisting of N substrings. Returns 0 if str is not in strlist or if strlist is the empty string. Returns NULL if either argument is NULL. If you want to find all the records that have 'North' you query will look something like this SELECT * FROM table_name WHERE FIND_IN_SET('North',regions_field)0 Dobromir Velev -Original Message- From: Joseph Koenig [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, June 28, 2001 4:50 AM Subject: [PHP-DB] Modify Query, or sift through results? I've got a script that searches a db every night and sends out e-mail if it finds something a person would be interested in, based on criteria they gave us. The problem is that I have one field that stores regions of the country in a very unpleasant way. It stores them as: Northeast;West;South So all of the regions for one record go into one field. The problem is that when searching that, if someone has a preference of 'North', I dont want to pull records that have 'Northeast', as would happen with the above example. Is there a way to modify the MySQL query so as to find only 'North', keeping in mind that 'North' may be the 3rd in a list of semi-colon separated regions? Or do I need to sift through the results in PHP to clean them up? Thanks, Joe -- 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]
Re: [PHP-DB] delay script
Hi, You can do this without using a php script why don't you use META HTTP-EQUIV="refresh" CONTENT="N;URL=http://www.foo.com/foo.html" where "N" represents a discrete time interval in seconds. Dobromir Velev -Original Message- From: Jennifer Arcino Demeterio [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, June 28, 2001 4:46 PM Subject: [PHP-DB] delay script hello! does anyone knows how to delay a display of a certain page ... for example, if i will click on "logout" button, it will show a page which will say "logging out" then after 5 seconds it will redirect to the login page. thanks =) -- 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]
Re: [PHP-DB] php/mysql horizontal listing query
Hi, may be this will be helpfull $res=mysql_query(select release from tbl_release); for ($i=1;$i=4;$i++){ if ($i==1)echo tr; $row=mysql_fetch_row($res); if ($row) echo TD$row[0]/TD; else { $end=1; echo tdnbsp;/td; } if ($i!=4)echo 'TDnbsp;/TD'; if ($i==4){ echo /TR; if (!$end)$i=0; } } Dobromir Velev -Original Message- From: Matt Nigh [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, June 27, 2001 4:33 AM Subject: [PHP-DB] php/mysql horizontal listing query hello knowledgeable people of the php-db list, i have a question for you regarding PHP using MySQL. my problem is this: I need a section of a record label site with a releases section listed horizontally but here's the twist: after every 4 releases, I want the releases to move to the next columns below. ex. release#1, release#2, release#3, release#4 release#5, release#6 each release is stored in a database called almavale_releases and there are 6 rows: id, bandname, albumtitle, coverpic, albumcode, datereleased so what i need to know is what php code do I need to accomplish this? your help is greatly appreciated and give my thanks in advance. email me offlist with your solutions/suggestions or send it to the list. it's great to see the php/db experts sharing their knowledge with the not-so-experts like myself on this list, I learn new stuff all the time on this great list! Matt -- 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]
Re: [PHP-DB] Connecting to MySQL
Hi, the @localhost is to show the database server you are trying to log on and it has nothing to do with your problem. Please check your username and password and if you have the right permissions. Dobromir Velev -Original Message- From: Keith Whyman [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, June 21, 2001 8:31 PM Subject: [PHP-DB] Connecting to MySQL Can anyone help with this problem ! user name should just be keith but the @localhost gets added and then I can't connect ??? Warning: MySQL Connection Failed: Access denied for user: 'keith@localhost' (Using password: YES) in /usr/var/www/www.happy.de/html/cms/test.php on line 23 Problem connecting to DataBase -- 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]
Re: [PHP-DB] MySQL connection: Change on syntaxis?
Hi, the '@' is an error control operator avaialble in all php versions. When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored. Check the PHP Manual for more info. Dobromir Velev -Original Message- From: Tomás García Ferrari [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Date: Friday, June 22, 2001 7:33 AM Subject: [PHP-DB] MySQL connection: Change on syntaxis? Hello, I updated php to version 4.0.5 and MySQL to version 2.32.39, had errors on lines like this: $rows = mysql_num_rows($result); and noticed that this is a solution: $rows = @mysql_num_rows($result); Is this a new use of the function mysql_num_rows? +-- --+ Tomás García Ferrari Bigital http://bigital.com/ +-- --+ -- 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]
Re: [PHP-DB] Date field
Hi, it depends on the the MySQL date type you are using. Here are the formats for the different types. DATE - '-MM-DD' DATETIME - '-MM-DD HH:MM:SS' TIMESTAMP(14) - MMDDHHMMSS TIMESTAMP(12) - YYMMDDHHMMSS TIMESTAMP(8) -MMDD TIMESTAMP(6) -YYMMDD TIME - 'HH:MM:SS' YEAR(4) - YEAR(2) - you can use 'YY' here if you use years between 1970 and 2069 Dobromir Velev -Original Message- From: Rosen [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, June 20, 2001 10:57 PM Subject: [PHP-DB] Date field Hi, Can someone tell me how do stote date field in MySQL DB ? Thanks, Rosen M. -- 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]
Re: [PHP-DB] raw file header in http
Hi, I think you could use something like this $file_name=/tmp/your_file_name; Header ( Content-Type: application/octet-stream); Header ( Content-Length: .filesize($file_name)); Header( Content-Disposition: inline; filename=$file_name); readfile($file_name); If you want instead of using application/octet-stream you can can use the MIME type of the file you are sending for example application/x-compressed. The second and the third headers are optional. Dobromir VElev -Original Message- From: schiarat@libero. [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, June 21, 2001 6:03 PM Subject: [PHP-DB] raw file header in http I' ve a file in a directory(/tmp) out from http root of web server. I need to open a page that send this file when it is opened (es.: opening page.php under netscape it opens a request to save file to disk, but the file is out of www root), i think i t is possible using command header and a raw http command, but i aven't any idea if it is possible and if yes in what mode. The system i use is apache 1.3.9 under redhat linux 7.1, tank's Omar -- 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]