Re: [PHP] my paging task with PHP does not work. It uses cookie.
Hi Arvid, thank you very much for your remark. It is useful for me. === On Fri, 14 Sep 2007 12:01:40 +0300 Arvids Godjuks [EMAIL PROTECTED] wrote: Don't use SQL_CALC_FOUND ROWS on simple queries, when you have to run a simple query on one or two (with join) tables with a simple WHERE. Especialy if tables are big. I found out that single SELECT COUNT(id) FROM table is far more faster when query has simple WHERE conditions. I use SQL_CALC_FOUND_ROWS only with a rather complex queries - that SQL_CALC_FOUND_ROWS doesn't affect query execution at all (well, it affects ofcourse, but affect is so small, you can't see it). -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] my paging task with PHP does not work. It uses cookie.
Dear Brian, My problem is solved. thank you very much for your help. === On Wed, 12 Sep 2007 14:04:11 -0400 brian [EMAIL PROTECTED] wrote: Patrik Hasibuan wrote: Dear my friends... I am trying to display the content of a table. Each page must content only 5 records maximum. Each page has Previous and Next buttons (made from anchor). I dump the primary of the working table and keep it in a cookie. So than the paging task work with the index of cookie array. But the $curguruescomidiklan stays 0 each time I click Next button. Patrick, i can't say what the problem is, but i recommend using the PEAR Pager package for this if you have PEAR available. It takes care of a lot of the heavy lifting and is very configurable. http://pear.php.net/package/Pager This does not require setting any cookies. brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] my paging task with PHP does not work. It uses cookie.
Dear mike, your thread solved my problem. I really appreciate your help. Thank you very much. On Thu, 13 Sep 2007 14:49:29 -0700 mike [EMAIL PROTECTED] wrote: warning: this is VERY UGLY CODE. i wrote it 3-4 years ago now i think and it just keeps working. you call it this way: # pagination. if(isset($_GET['pg'])) { $page = intval($_GET['pg']); } else { $page = 1; } $page = sprintf(%02d,$page); $query = Array( 'query' = SELECT foo FROM bar, 'itemsperpage' = 50, 'maxdisplay'= 20, 'linkprefix'= $_SERVER[PHP_SELF]?f=$forum_idpg= ); list($pages,$numpages,$items,$threads) = paginate_sql($page,$query); $pages is the html formatted links $numpages is the total number of pages i dont actually use $items much but i think it just tells you how many items (which is the same as itemsperpage... i believe) $threads is the mysql rows resource (you can use mysql_fetch_rows on it) function paginate_sql($thispage,$options) { $offset = $options['itemsperpage'] * ($thispage - 1); if(isset($options['server'])) { $results = db_query(eregi_replace(^SELECT,SELECT SQL_CALC_FOUND_ROWS,$options['query']).LIMIT $offset,$options[itemsperpage],$options['server']); $rows = db_query(SELECT FOUND_ROWS(),$options['server']); } else { $results = db_query(eregi_replace(^SELECT,SELECT SQL_CALC_FOUND_ROWS,$options['query']).LIMIT $offset,$options[itemsperpage]); $rows = db_query(SELECT FOUND_ROWS()); } list($totalitems) = db_rows($rows); db_free($rows); $html = ; $numpages = ceil($totalitems / $options['itemsperpage']); if(isset($options['maxpages']) $numpages $options['maxpages']) { $numpages = $options['maxpages']; } if($thispage 1 || $totalitems $options['itemsperpage']) { $thispage = sprintf(%02d,1); } if($thispage $numpages $numpages 0) { header(sprintf(Location: %s01, str_replace(amp;,,$options['linkprefix']))); exit(); } $start = (ceil($thispage / $options['maxdisplay'])-1) * $options['maxdisplay'] + 1; if($start == 1) { $html .= laquo;; } else { $html .= sprintf(a href=\%s%02d\laquo;/a, $options['linkprefix'], $start-1); } if(isset($options['maxdisplay']) $options['maxdisplay'] != 0 $numpages $options['maxdisplay']) { $numlist = $options['maxdisplay'] + $start - 1; } else { $numlist = $numpages + $start - 1; } if($numlist $numpages) { $numlist = $numpages; } for($x=$start; $x=$numlist; $x++) { if($x == $thispage) { $html .= sprintf( %02d, $x); } else { $html .= sprintf( a href=\%s%02d\%02d/a, $options['linkprefix'], $x, $x); } } if($numlist == $numpages) { $html .= raquo;; } else { $html .= sprintf( a href=\%s%02d\raquo;/a, $options['linkprefix'], $numlist+1); } if($totalitems = $options['itemsperpage']) { $html = ; } return Array($html,sprintf(%02d,$numpages),$totalitems,$results); } On 9/13/07, Patrik Hasibuan [EMAIL PROTECTED] wrote: Hi Mike, I am intrested for the solution you gave me. But I am confused of the way in implementing select FOUND_ROWS(). I wrote another very simple codes as the first step for understanding this threat: ?php $konek=mysql_connect(127.0.0.1,root,mypassword); if ($konek){ for ($i=0;$i2;$i++){ $sqlku=select SQL_CALC_FOUND_ROWS id_iklan from lowongan limit 5;; $sqlkupage=select FOUND_ROWS(); $mybd=mysql_select_db(headhunter,$konek); $kueri=mysql_query($sqlku,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek)); $kueri=mysql_query($sqlkupage,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek)); while($brs=mysql_fetch_row($kueri)){ list($idiklan)=$brs; echo FirstItem a href=\showit.php?id=$idiklan\$idiklan/abr; } } }else{ echo I can't talk to the serverbr; exit(); } ? I've put nine records into the table of lowongan, idiklan 1 to 9. Look I get of course only one record, namely the: '9'. This is the output of my codes in my internet browser. === FirstItem 9 FirstItem 9 === The output what I am expecting suppose to be: on the $i=0 FirstItem 1 FirstItem 2 FirstItem 3 FirstItem 4 FirstItem 5 and on the $i=1 FirstItem 6 FirstItem 7 FirstItem 8 FirstItem 9 FirstItem 9 I read on the documentation of MySQL but I couldn't find any code of sample also
Re: [PHP] my paging task with PHP does not work. It uses cookie.
Hi Mike, I am intrested for the solution you gave me. But I am confused of the way in implementing select FOUND_ROWS(). I wrote another very simple codes as the first step for understanding this threat: ?php $konek=mysql_connect(127.0.0.1,root,mypassword); if ($konek){ for ($i=0;$i2;$i++){ $sqlku=select SQL_CALC_FOUND_ROWS id_iklan from lowongan limit 5;; $sqlkupage=select FOUND_ROWS(); $mybd=mysql_select_db(headhunter,$konek); $kueri=mysql_query($sqlku,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek)); $kueri=mysql_query($sqlkupage,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek)); while($brs=mysql_fetch_row($kueri)){ list($idiklan)=$brs; echo FirstItem a href=\showit.php?id=$idiklan\$idiklan/abr; } } }else{ echo I can't talk to the serverbr; exit(); } ? I've put nine records into the table of lowongan, idiklan 1 to 9. Look I get of course only one record, namely the: '9'. This is the output of my codes in my internet browser. === FirstItem 9 FirstItem 9 === The output what I am expecting suppose to be: on the $i=0 FirstItem 1 FirstItem 2 FirstItem 3 FirstItem 4 FirstItem 5 and on the $i=1 FirstItem 6 FirstItem 7 FirstItem 8 FirstItem 9 FirstItem 9 I read on the documentation of MySQL but I couldn't find any code of sample also in the php.net. Would be so kind to give me a very simple code of sample? Thank you very much in advance. On Wed, 12 Sep 2007 11:58:04 -0700 mike [EMAIL PROTECTED] wrote: On 9/12/07, Patrik Hasibuan [EMAIL PROTECTED] wrote: Dear my friends... I am trying to display the content of a table. Each page must content only 5 records maximum. Each page has Previous and Next buttons (made from anchor). I dump the primary of the working table and keep it in a cookie. So than the paging task work with the index of cookie array. But the $curguruescomidiklan stays 0 each time I click Next button. yeah there is no reason to be using cookies for this. just using query string parameters should work. for pagination you need to know: total number of items number of items per page after that you know how many pages (numitems / itemsperpage) and work out the links appropriately (i.e. page1 has no previous, $maxpage has no next) and you can put the number of pages down how you want (if you want to do prev 3 4 5 next, or next 1 2 3 4 5 6 7 8 9 prev, there's a ton of strategies to print out what pages to show, and next, previous, jump to end, jump to beginning, etc) i've never used the PEAR class or anything else, i made a function a long time ago that actually works in conjunction with mysql's SELECT FOUND_ROWS() and uses a LIMIT offset,number to save the overhead of fetching every row from the database to only show the ones for that page. it's actually worked well for 4 years now without a single change... at some point perhaps i'll clean it up and post it somewhere, and someone might be able to make it even better. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] my paging task with PHP does not work. It uses cookie.
Dear my friends... I am trying to display the content of a table. Each page must content only 5 records maximum. Each page has Previous and Next buttons (made from anchor). I dump the primary of the working table and keep it in a cookie. So than the paging task work with the index of cookie array. But the $curguruescomidiklan stays 0 each time I click Next button. The main part of doing the paging task is this lines: for ($it=$curguruescomidiklan;$it$itot;$it++){ $idad=$guruescomidiklan[$it]; echo idad= $idadbr; echo it: $itbr; bukaiklan($idad); } . Please tell me why PHP does not work as I expect. Thank you very much in advance. = html ?php session_start(); session_register(tiket); setcookie(curguruescomidiklan); setcookie(guruescomidiklan,); setcookie(jmli); $tiket=session_id(); $pageamount = 5; ? table align=center tr !--Bagian Pencari Kerja-- td valign=top background=gambar/gbkiri.gif table align=right border=0 cellpadding=0 cellspacing=0 width=300 tr td align=left table border=1 cellpadding=0 cellspacing=0 ?php if ($curguruescomidiklan0){ echo trtda href=\index.php?p=t\ style=\text-decoration:none;\Previous/a/td/tr; } ? /table /td td/td td align=right table border=1 cellpadding=0 cellspacing=0 trtd ?php if (($jmli % $curguruescomidiklan)1 or $curguruescomidiklan==0){ echo a href=\index.php?p=n\ style=\text-decoration:none;\Next/a/td/tr; } ? /td/tr /table /td /tr trtd ?php echo trth colspan=12Lowongan Kerja/th/tr; include_once koneksi.php; $sqlnya= select l.id_iklan from perusahaan as p right join lowongan as l on l.id_account=p.id_account where l.lama_tayang = (current_date-l.mulai_tayang) order by bid desc ; $kelas=new koneksi(); $klas=$kelas-getkoneksi(headhunter,$sqlnya); $jmli=mysql_num_rows($klas); if ( $jmli 0 ) { $i=0; while(list($idiklan)=mysql_fetch_row($klas)) { // echo ID Iklannya: $idiklanbr; setcookie(guruescomidiklan[$i],$idiklan); $i++; } } else { echo No Ad of job vacancy currently in our databasebr; } if (empty($curguruescomidiklan)){ $curguruescomidiklan=0; } //echo pa: $pageamountbr; if (isset($p)){ $nt=$_GET['p']; } //I meant this part should direct the page content to be the next array contents if ($jmli=$pageamount){ echo curguruescomidiklan --$curguruescomidiklanbr; if ($nt=='t'){ $itot=$_COOKIE['curguruescomidiklan']-$pageamount; }else{ $itot=$_COOKIE['curguruescomidiklan']+$pageamount; echo lewat sini $curguruescomidiklan $pageamountbr; } echo itot 1 --$itotbr; }else{ $itot=$jmltot; echo itot 2 --$itotbr; } for ($it=$curguruescomidiklan;$it$itot;$it++){ $idad=$guruescomidiklan[$it]; echo idad= $idadbr; echo it: $itbr; bukaiklan($idad); } $itot=$itot+$pageamount; setcookie(curguruescomidiklan,$itot); echo curguruescomidiklan-- $curguruescomidiklanbr; function bukaiklan($myid){ //echo myid=$myidbr; $sqlnya= select p.company_fullname, p.company_address, p.city, p.country, p.postcode, p.phone, p.fax, p.url, p.company_description, l.iklan, l.id_iklan from perusahaan as p right join lowongan as l on l.id_account=p.id_account where l.lama_tayang = (current_date-l.mulai_tayang) and l.id_iklan='$myid' order by bid desc ; $kelassqlbukaiklan=new koneksi(); $klassqlbukaiklan=$kelassqlbukaiklan-getkoneksi(headhunter,$sqlnya); if ( mysql_num_rows($klassqlbukaiklan) 0 ) { while(list($namaprsh, $alamat, $kota, $negara, $kodepos, $telfon, $faks, $url, $comdesc, $iklan, $idiklan)=mysql_fetch_row($klassqlbukaiklan)) { echo trtd valign=\top\Employer/tdtd valign=\top\:/tdtd valign=\top\ colspan=10$namaprsh/td/tr; echo trtd valign=\top\Address/tdtd valign=\top\:/tdtd valign=\top\ colspan=10$alamat/td/tr; echo trtd valign=\top\City/tdtd valign=\top\:/tdtd valign=\top\ colspan=10$kota/td/tr; echo trtd valign=\top\Country/tdtd valign=\top\:/tdtd valign=\top\ colspan=10$negara/td/tr; echo trtd valign=\top\Postcode/tdtd valign=\top\:/tdtd colspan=10 valign=\top\$kodepos/td/tr; echo trtd valign=\top\Fax/tdtd valign=\top\:/tdtd valign=\top\ colspan=10$faks/td/tr; echo trtd valign=\top\Website/tdtd valign=\top\:/tdtd colspan=10 valign=\top\$url/td/tr; echo trtd valign=\top\Business Field/tdtd valign=\bottom\:/tdtd valign=\bottom\ colspan=10$comdesc/td/tr; echo trtd colspan=12$iklan/td/tr; echo trtd colspan=12 height=16/td/tr; } } else { echo No Ad of job vacancy currently in our database, possibly ads-id wrong.br; } } ? /td/tr/table /td !--Bagian Toko Buku Guru-- td valign=top /td !--Bagian Employer-- td valign=top /td /tr /table /body /html -- Patrik
[PHP] clickbank (merchandise provider) for creditcard based internet online transaction.
Dear all of my friends in this mailing-list, Has anybody here ever tried creating a creditcard based internet online transaction with PHP to clickbank (http://www.clickbank.com)? Which PHP Library should I use to develop the payment process? Can I use CURL for clickbank? Among all of my friends in this mailing-list, has anybody ever get problem or find the disadvantage to use the service of clickbank? Thank you very much in advance. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Does JavaScript not work in php web file?
Dear Sanjeev, you're right. I am sorry for my carelessness. I corrected my code and than try it again. But again, it does not work as I expect. I even put prompt(this function is being called); in the jsopsi() but again the prompt does not come out. Pffuih... I am desperate only because of this small thing. Please keep telling me what's wrong with my code. Do I have to write the JavaScript in another way if the javascript is placed in php file? == //This is my current code: !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org TITLEguru.com - Menu for new customer/TITLE Script Language=JavaScript function jsopsi(){ prompt(This prompt comes out if this function is really being called); if (document.formulir.opsinegara.value!=Virgina Islands (USA);){ document.formulir.opsistate.options[5].selected=true; } } /Script /head BODY ?php if (isset($pid)){ $idproduk=$_GET['pid']; echo Produk ID: $idprodukbr; } ? table border=0 align=center cellpadding=0 cellspacing=0 width=800 trtd/tdtdtable border=0 align=center cellpadding=0 cellspacing=0 width=400 form method=post action=cgi/cgipelangganbaru.php?pid=$idproduk name=formulir tr td align=right bgcolor=#F5D78B 3. Country: /td td align=center /td td align=left select name=negara onchange=jsopsi() name=opsinegara ?php include_once koneksi.php; $sqlnya=select country from countries; $kelas=new koneksi(); $klas=$kelas-getkoneksi(survey,$sqlnya); if ( mysql_num_rows($klas) 0 ) { while( list($negara) = mysql_fetch_row($klas) ) { echo option id=\opsi.$negara\ value=\$negara\$negara/option; } } else { echo 'No results found'; } ? /select /td /tr tr td align=right bgcolor=#F5D78B 4. State: /td td align=center /td td align=left select name=opsistate ?php include_once koneksi.php; $sqlnya=select state,statename from states; $kelas=new koneksi(); $klas=$kelas-getkoneksi(survey,$sqlnya); if ( mysql_num_rows($klas) 0 ) { echo option name=\state\ value=\\/option; while( list($state,$statename) = mysql_fetch_row($klas) ) { echo option name=\state\ value=\$state\$statename ($state)/option; } } else { echo 'No results found'; } ? /select /td /tr /form /table /tdtd/td/tr/table /BODY /HTML == On Sat, 25 Aug 2007 22:26:49 +0530 Sanjeev N [EMAIL PROTECTED] wrote: Hi, JavaScript codes works in php files. Yours code is also fine. But check your calling function and defined functions. Calling function is jsopsi and defined function is opsi. Please check. Other than this everything is ok Warm Regards, Sanjeev http://www.sanchanworld.com/ http://webdirectory.sanchanworld.com - Submit your website URL http://webhosting.sanchanworld.com - Choose your best web hosting plan -Original Message- From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] Sent: Saturday, August 25, 2007 9:17 PM To: php-general@lists.php.net Subject: [PHP] Does JavaScript not work in php web file? Dear my friends... I am confused to implement JavaScript code in php web file. I want my JavaScript change the selected item of select tag based on the selected item of previous selected in same php page. Please help me tell my where is my mistake. === Here is my code pelangganbaru.php === !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org TITLEguru.com - Menu for new customer/TITLE /HEAD Script Language=JavaScript function opsi(){ if (document.formulir.opsinegara.value!=Virgina Islands (USA);){ document.formulir.opsistate.options[0].selected=true; } } /Script BODY ?php if (isset($pid)){ $idproduk=$_GET['pid']; echo Produk ID: $idprodukbr; } ? table border=0 align=center cellpadding=0 cellspacing=0 width=800 trtd/tdtdtable border=0 align=center cellpadding=0 cellspacing=0 width=400 form method=post action=cgi/cgipelangganbaru.php?pid=$idproduk name=formulir tr td align=right bgcolor=#F5D78B 3. Country: /td td align=center /td td align=left select name=negara onchange=jsopsi() name=opsinegara ?php include_once koneksi.php; $sqlnya=select country from countries; $kelas=new koneksi(); $klas=$kelas-getkoneksi(survey,$sqlnya); if ( mysql_num_rows($klas) 0 ) { while( list($negara) = mysql_fetch_row($klas) ) { echo option id=\opsi.$negara\ value=\$negara\$negara/option
[PHP] Does JavaScript not work in php web file?
Dear my friends... I am confused to implement JavaScript code in php web file. I want my JavaScript change the selected item of select tag based on the selected item of previous selected in same php page. Please help me tell my where is my mistake. === Here is my code pelangganbaru.php === !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org TITLEguru.com - Menu for new customer/TITLE /HEAD Script Language=JavaScript function opsi(){ if (document.formulir.opsinegara.value!=Virgina Islands (USA);){ document.formulir.opsistate.options[0].selected=true; } } /Script BODY ?php if (isset($pid)){ $idproduk=$_GET['pid']; echo Produk ID: $idprodukbr; } ? table border=0 align=center cellpadding=0 cellspacing=0 width=800 trtd/tdtdtable border=0 align=center cellpadding=0 cellspacing=0 width=400 form method=post action=cgi/cgipelangganbaru.php?pid=$idproduk name=formulir tr td align=right bgcolor=#F5D78B 3. Country: /td td align=center /td td align=left select name=negara onchange=jsopsi() name=opsinegara ?php include_once koneksi.php; $sqlnya=select country from countries; $kelas=new koneksi(); $klas=$kelas-getkoneksi(survey,$sqlnya); if ( mysql_num_rows($klas) 0 ) { while( list($negara) = mysql_fetch_row($klas) ) { echo option id=\opsi.$negara\ value=\$negara\$negara/option; } } else { echo 'No results found'; } ? /select /td /tr tr td align=right bgcolor=#F5D78B 4. State: /td td align=center /td td align=left select name=opsistate ?php include_once koneksi.php; $sqlnya=select state,statename from states; $kelas=new koneksi(); $klas=$kelas-getkoneksi(survey,$sqlnya); if ( mysql_num_rows($klas) 0 ) { echo option name=\opsi.$state.\ value=\\/option; if ($negara==Virgin Islands (US)){ echo option name=\nonusa\ value=\00\ selectedNon USA/option; }else{ echo option name=\nonusa\ value=\00\Non USA/option; } while( list($state,$statename) = mysql_fetch_row($klas) ) { echo option name=\state\ value=\$state\$statename ($state)/option; } } else { echo 'No results found'; } ? /select /td /tr tr td align=right input type=submit /td td align=center /td td align=left input type=reset /td /tr /form /table /tdtd/td/tr/table /BODY /HTML -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] OOP in PHP
Dear my friends, This is the first time for me to use OOP concept of PHP. I wrote still a very simple codes but it doesn't work as my manual book taught. the book titled MySQL/PHP Database Application by Jay Greenspan say these lines should work but in fact it don't work as expected. Here is my code: === //pelangganbaru.php ?php require koneksi.php; $sqlnya=select country from countries; $klas=new koneksi($sqlnya); ? === //koneksi.php !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org /HEAD BODY ?php class koneksi{ $namakompie=127.0.0.1; $un=root; $pw=mysqlpw; $sqlnya; $kueri; function koneksi($sqlnya){ echo superclass koneksi dipanggilbr; $konek=mysql_connect($namakompie,$un,$pw); if ($konek){ echo koneksi berhasil (connection succeeded)br; $mybd=mysql_select_db(survey,$konek); $kueri=mysql_query($sqlnya,$konek); }else{ echo I can't talk to the serverbr; exit(); } return $kueri; } } ? /BODY /HTML = Theoritically if Class koneksi is being initialized than it prints koneksi berhasil (connection succeeded) but it doesn't. Please tell me what is my mistake. Thank you very much in advance. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP in PHP
Dear Jim, You've solved my problem, Jim. Thank you very much. Now, my code give the output as my expectation: superclass koneksi dipanggil koneksi berhasil negara- . But come another problem, namely: the $negara is empty. I tried to read the documentation on http://www.php.net/manual/en/language.types.object.php#language.types.object.casting but I didn't manage to find the answer. I suspect the return $kueri could be only for 'returning' a variable of boolean or string or number but not 'returning' an array (such as the result of mysql_query(select country from countries,$koneksi) ) or an object (such as the result of mysql_connect() ). So how should I get the content of mysql_query() so I can get the value with mysql_fetch_row() or inherit array? Is is also possible to re-use the result of mysql_connect() or inherit the $konek? Here is my current code: //pelangganbaru.php ?php include_once koneksi.php; $sqlnya=select country from countries; $klas=new koneksi($sqlnya); $brs=mysql_fetch_row($klas-kueri); list($negara)=$brs; echo option value=\$negara\$negara/option; ? = //koneksi.php !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org /HEAD BODY ?php class koneksi{ var $namakompie=127.0.0.1; var $un=root; var $pw=mysuccess; var $sqlnya; var $kueri; function koneksi($sqlnya){ echo superclass koneksi dipanggilbr; $konek=mysql_connect($this-namakompie,$this-un,$this-pw); if ($konek){ echo koneksi berhasilbr; $mybd=mysql_select_db(survey,$konek); $kueri=mysql_query($sqlnya,$konek); }else{ echo I can't talk to the serverbr; exit(); } return $kueri; } } ? /BODY /HTML Please keep telling me. Thank you very much in advance. ps: Thanks a lot too to Nathan Nobe and Robert Gegen for their responds... On Wed, 15 Aug 2007 09:00:56 -0700 Jim Lucas [EMAIL PROTECTED] wrote: A few missing pieces in your code. Take a look below within your class. I corrected it. try also using include_once instead of require and make sure that your error level and reporting are turned on so you can see what is happening. Patrik Hasibuan wrote: Dear my friends, This is the first time for me to use OOP concept of PHP. I wrote still a very simple codes but it doesn't work as my manual book taught. the book titled MySQL/PHP Database Application by Jay Greenspan say these lines should work but in fact it don't work as expected. Here is my code: === //pelangganbaru.php ?php require koneksi.php; $sqlnya=select country from countries; $klas=new koneksi($sqlnya); ? === //koneksi.php !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org /HEAD BODY ?php class koneksi{ $namakompie=127.0.0.1; var $namakompie='127.0.0.1'; $un=root; var $un='root'; $pw=mysqlpw; var $pw='mysqlpw'; $sqlnya; var $sqlnya; $kueri; var $kueri; function koneksi($sqlnya){ echo superclass koneksi dipanggilbr; $konek=mysql_connect($namakompie,$un,$pw); $konek=mysql_connect($this-namakompie, $this-un, $this-pw); if ($konek){ echo koneksi berhasil (connection succeeded)br; $mybd=mysql_select_db(survey,$konek); $kueri=mysql_query($sqlnya,$konek); }else{ echo I can't talk to the serverbr; exit(); } return $kueri; } } ? /BODY /HTML = Theoritically if Class koneksi is being initialized than it prints koneksi berhasil (connection succeeded) but it doesn't. Please tell me what is my mistake. Thank you very much in advance. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] OOP in PHP
Dear Jim, thanks for your help. I've modified my codes as you adviced. But than the output is: superclass koneksi dipanggil koneksi berhasil No results found The column 'country' of table 'countries' already really contents complete all contry name from all over the earth. How come the query of select country from countries results empty value. So I believe the problem is still on the my OOP programming because if I do the query only with the procedural concept the $kueri will content the complete record of the column country. Please keep telling what is my mistake on my OOP PHP5 codes. - //pelangganbaru.php ?php include_once koneksi.php; $sqlnya=select * from countries; $klas=new koneksi($sqlnya); if ( mysql_num_rows($klas) 0 ) { while( list($negara) = mysql_fetch_row($klas) ) { echo negara-$negarabr; } } else { echo 'No results found'; } ? - //koneksi.php !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org /HEAD BODY ?php class koneksi{ var $namakompie=127.0.0.1; var $un=root; var $pw=mysuccess; var $sqlnya; var $kueri; function koneksi($sqlnya){ echo superclass koneksi dipanggilbr; $konek=mysql_connect($this-namakompie,$this-un,$this-pw); if ($konek){ echo koneksi berhasilbr; $mybd=mysql_select_db(survey,$konek); //$kueri=mysql_query($sqlnya,$konek); $kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek)); }else{ echo I can't talk to the serverbr; exit(); } return $kueri; } } ? /BODY /HTML === On Wed, 15 Aug 2007 13:13:18 -0700 Jim Lucas [EMAIL PROTECTED] wrote: Patrik Hasibuan wrote: Dear Jim, You've solved my problem, Jim. Thank you very much. Now, my code give the output as my expectation: superclass koneksi dipanggil koneksi berhasil negara- . But come another problem, namely: the $negara is empty. I tried to read the documentation on http://www.php.net/manual/en/language.types.object.php#language.types.object.casting but I didn't manage to find the answer. I suspect the return $kueri could be only for 'returning' a variable of boolean or string or number but not 'returning' an array (such as the result of mysql_query(select country from countries,$koneksi) ) or an object (such as the result of mysql_connect() ). So how should I get the content of mysql_query() so I can get the value with mysql_fetch_row() or inherit array? Is is also possible to re-use the result of mysql_connect() or inherit the $konek? Here is my current code: //pelangganbaru.php ?php include_once koneksi.php; $sqlnya=select country from countries; $klas=new koneksi($sqlnya); Try this instead if ( mysql_num_rows($klas) 0 ) { while( list($negara) = mysql_fetch_row($klas) ) { echo option value=\$negara\$negara/option; } } else { echo 'No results found'; } And within your class change your mysql_query line to this $kueri=mysql_query($sqlnya,$konek) or die('MYSQL QUERY ERROR ['.mysql_errno($konek).'] '.mysql_error($konek)); This will make the system fail and kill the script if the query fails for some reason. The die() part will then print the error number and what mysql thinks is wrong. This isn't the best way to use error reporting in a production system, but since you are new at this, this is a simple way to do error reporting. It is always a good idea to use is_resource($resource_handle_from_mysql) as a test to see if you did in fact get a valid resource id from the mysql_connect() call. $brs=mysql_fetch_row($klas-kueri); list($negara)=$brs; echo option value=\$negara\$negara/option; ? = //koneksi.php !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN HTML HEAD META name=generator content=HTML Tidy for Linux/x86 (vers 31 October 2006), see www.w3.org /HEAD BODY ?php class koneksi{ var $namakompie=127.0.0.1; var $un=root; var $pw=mysuccess; var $sqlnya; var $kueri; function koneksi($sqlnya){ echo superclass koneksi dipanggilbr; $konek=mysql_connect($this-namakompie,$this-un,$this-pw); if ($konek){ echo koneksi berhasilbr; $mybd=mysql_select_db(survey,$konek); $kueri=mysql_query($sqlnya,$konek); }else{ echo I can't talk to the serverbr; exit(); } return $kueri; } } ? /BODY /HTML Please keep telling me. Thank you very much in advance. ps: Thanks a lot too to Nathan Nobe and Robert Gegen for their responds... On Wed, 15 Aug 2007 09:00:56 -0700 Jim Lucas [EMAIL PROTECTED] wrote: A few missing pieces in your code
Re: [PHP] OOP in PHP
Dear my friend, Jim Lucas. Thank you very much for your help. You've solved my problem one more time. I really appreciate your help. === On Wed, 15 Aug 2007 14:17:02 -0700 Jim Lucas [EMAIL PROTECTED] wrote: Jim Lucas wrote: Patrik Hasibuan wrote: Dear Jim, thanks for your help. I've modified my codes as you adviced. But than the output is: superclass koneksi dipanggil koneksi berhasil No results found The column 'country' of table 'countries' already really contents complete all contry name from all over the earth. How come the query of select country from countries results empty value. So I believe the problem is still on the my OOP programming because if I do the query only with the procedural concept the $kueri will content the complete record of the column country. Please keep telling what is my mistake on my OOP PHP5 codes. - //pelangganbaru.php ?php include_once koneksi.php; $sqlnya=select * from countries; ok, don't know why it took me this long to realize what the problem is. The following line will return the object of a the class that you are initializing, not the result set pointer. So, what you need to do is this Change this function koneksi($sqlnya){ ... } to this function getkoneksi($sqlnya) { oops this should be get_koneksi($sqlnya) ... } Then this $klas=new koneksi($sqlnya); to this $o = new koneksi(); $klas = $o-get_koneksi($sqlnya); Now all should work. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] subtitute of mysql_error()
Dear my friends What is the substitute of mysql_error() ? This line of my code does not work anymore: $hslgbr=mysql_query($sqlgbr,$konek) or die ( mysql_error() ); Thank you very much in advance. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] I am confused to mysql_query.
Dear my friends... This sql string produces proper output in my MySQL-Query: select image_src from products where product_id='10'; the output is: gambarproduk/0/10/1.jpg But my php code does not produce anything. Please tell me what is my mistake. === ?php if (isset($pid)){ $koneksi=mysql_connect(127.0.0.1,root,mysuccess); $stringsql=select style, description, price from styles where product_id='$pid';; $hsl=mysql_query($stringsql,$koneksi); while ($brs=mysql_fetch_row($hsl)){ list($edisi,$deskripsi,$harga)=$brs; } $konek=mysql_connect(127.0.0.1,root,mysuccess); if ($konek){ echo konek berhasil br; $sqlgbr=select image_src from products where product_id='$pid';; echo $sqlgbr br; $hslgbr=mysql_query($sqlgbr,$konek); if (!$hslgbr){ echo query gambarproduk tidak berhasil br; }elseif ($hslgbr){ echo array gambar; } while ($brsgbr=mysql_fetch_row($hslgbr)){ list($gambarproduk)=$brsgbr; echo urlgambar: $gambarproduk br; } } } ? === -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global variable does not exist anymore?
OK, Thanks Richards. === On Wed, 25 Jul 2007 23:54:37 +0100 Richard Davey [EMAIL PROTECTED] wrote: Hi Patrik, Wednesday, July 25, 2007, 11:30:56 PM, you wrote: Dear my friends... I create a very simple script in html and php as a first step. I use suse, apache2, mysql and php. I wonder why this script does not work: !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=ISO-8859-1 http-equiv=content-type titleGuru - Virtual bookstore who understands you for those want to be a GURU/title /head body Help us for statistic data collection for increasing our service by 'filling our guestbook'.br form action=cgi/cgibukutamu.php method=post table trtd align=rightName: /tdtd align=leftinput type=text name=tfnama/td/tr trtd align=rightLocation: /tdtd align=leftinput type=text name=tflokasi/td/tr trtd align=rightE-Mail: /tdtd align=leftinput type=text name=tfemail/td/tr trtd align=rightURL: /tdtd align=leftinput type=text name=tfurl/td/tr trtd align=rightComments: /tdtd align=leftinput type=text name=tfkomentar/td/tr trtd align=rightinput type=submit/tdtd align=leftinput type=reset/td/tr /table /form /body /html The value of tfnama is empty. cgi/cgibukutamu.php html table trtd/tdtd/td/tr trtd align=rightName/tdtd align=left?php echo $tfnama ?/td/tr /table /html I had a look the into the /etc/apache2 but I didn't find any global_variable switch as I used to find in httpd.conf suseonthelap:/etc/apache2 # grep -n -r global_variable ./* suseonthelap:/etc/apache2 # I got used to find global_variable=on line in the httpd.conf. Try looking in php.ini Then leave it disabled, and code your script properly so it checks the user input and validates it before using it. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global variable does not exist anymore?
Thank you very much. === On Fri, 27 Jul 2007 00:26:24 -0500 (CDT) Richard Lynch [EMAIL PROTECTED] wrote: It's register_globals, and you should fix this ancient script to not rely on register_globals being on On Wed, July 25, 2007 5:30 pm, Patrik Hasibuan wrote: Dear my friends... I create a very simple script in html and php as a first step. I use suse, apache2, mysql and php. I wonder why this script does not work: !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=ISO-8859-1 http-equiv=content-type titleGuru - Virtual bookstore who understands you for those want to be a GURU/title /head body Help us for statistic data collection for increasing our service by 'filling our guestbook'.br form action=cgi/cgibukutamu.php method=post table trtd align=rightName: /tdtd align=leftinput type=text name=tfnama/td/tr trtd align=rightLocation: /tdtd align=leftinput type=text name=tflokasi/td/tr trtd align=rightE-Mail: /tdtd align=leftinput type=text name=tfemail/td/tr trtd align=rightURL: /tdtd align=leftinput type=text name=tfurl/td/tr trtd align=rightComments: /tdtd align=leftinput type=text name=tfkomentar/td/tr trtd align=rightinput type=submit/tdtd align=leftinput type=reset/td/tr /table /form /body /html The value of tfnama is empty. cgi/cgibukutamu.php html table trtd/tdtd/td/tr trtd align=rightName/tdtd align=left?php echo $tfnama ?/td/tr /table /html I had a look the into the /etc/apache2 but I didn't find any global_variable switch as I used to find in httpd.conf suseonthelap:/etc/apache2 # grep -n -r global_variable ./* suseonthelap:/etc/apache2 # I got used to find global_variable=on line in the httpd.conf. What should I do now? Please tell me. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I am confused to mysql_query.
Hi Sichta, That's what I am confused. Quoted or no Quote makes no effect. mysql_query does not work. I tried to debug with ..or die (mysql_error()); but it seems mysql_error() does not exist anymore. Please keep telling me. I've wasted to much time today hanging around with this weird problem. On Wed, 1 Aug 2007 08:27:51 +0200 Sichta, Daniel [EMAIL PROTECTED] wrote: Hi , Try this: $hsl=mysql_query($stringsql,$koneksi); DS -Original Message- From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 01, 2007 8:23 AM To: php-general@lists.php.net Subject: [PHP] I am confused to mysql_query. Dear my friends... This sql string produces proper output in my MySQL-Query: select image_src from products where product_id='10'; the output is: gambarproduk/0/10/1.jpg But my php code does not produce anything. Please tell me what is my mistake. === ?php if (isset($pid)){ $koneksi=mysql_connect(127.0.0.1,root,mysuccess); $stringsql=select style, description, price from styles where product_id='$pid';; $hsl=mysql_query($stringsql,$koneksi); while ($brs=mysql_fetch_row($hsl)){ list($edisi,$deskripsi,$harga)=$brs; } $konek=mysql_connect(127.0.0.1,root,mysuccess); if ($konek){ echo konek berhasil br; $sqlgbr=select image_src from products where product_id='$pid';; echo $sqlgbr br; $hslgbr=mysql_query($sqlgbr,$konek); if (!$hslgbr){ echo query gambarproduk tidak berhasil br; }elseif ($hslgbr){ echo array gambar; } while ($brsgbr=mysql_fetch_row($hslgbr)){ list($gambarproduk)=$brsgbr; echo urlgambar: $gambarproduk br; } } } ? === -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I am confused to mysql_query.
Sorry, for my recklessness I missed, $bdku=mysql_select_db(guru,$konek); Es ist peinlich It's embarassing. But thanks for your help. = On Wed, 1 Aug 2007 15:15:43 +0700 Patrik Hasibuan [EMAIL PROTECTED] wrote: Hi Sichta, That's what I am confused. Quoted or no Quote makes no effect. mysql_query does not work. I tried to debug with ..or die (mysql_error()); but it seems mysql_error() does not exist anymore. Please keep telling me. I've wasted to much time today hanging around with this weird problem. On Wed, 1 Aug 2007 08:27:51 +0200 Sichta, Daniel [EMAIL PROTECTED] wrote: Hi , Try this: $hsl=mysql_query($stringsql,$koneksi); DS -Original Message- From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 01, 2007 8:23 AM To: php-general@lists.php.net Subject: [PHP] I am confused to mysql_query. Dear my friends... This sql string produces proper output in my MySQL-Query: select image_src from products where product_id='10'; the output is: gambarproduk/0/10/1.jpg But my php code does not produce anything. Please tell me what is my mistake. === ?php if (isset($pid)){ $koneksi=mysql_connect(127.0.0.1,root,mysuccess); $stringsql=select style, description, price from styles where product_id='$pid';; $hsl=mysql_query($stringsql,$koneksi); while ($brs=mysql_fetch_row($hsl)){ list($edisi,$deskripsi,$harga)=$brs; } $konek=mysql_connect(127.0.0.1,root,mysuccess); if ($konek){ echo konek berhasil br; $sqlgbr=select image_src from products where product_id='$pid';; echo $sqlgbr br; $hslgbr=mysql_query($sqlgbr,$konek); if (!$hslgbr){ echo query gambarproduk tidak berhasil br; }elseif ($hslgbr){ echo array gambar; } while ($brsgbr=mysql_fetch_row($hslgbr)){ list($gambarproduk)=$brsgbr; echo urlgambar: $gambarproduk br; } } } ? === -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $HTTP_POST_FILES always produces empty value.
Thank you very much for your help, Richard. It's solved. On Tue, 31 Jul 2007 00:47:51 -0500 (CDT) Richard Lynch [EMAIL PROTECTED] wrote: Try this: echo _FILES:br /\n; var_dump($_FILES); echo br /\nHTTP_POST_FILESbr /\n; var_dump($HTTP_POST_FILES); On Mon, July 30, 2007 7:00 am, Patrik Hasibuan wrote: Dear my friends I don't understand why $HTTP_POST_FILES always produces empty value. This is my code === //cgi/cgiprodukcatalogadmin.php ?php $berkasgambarproduk=$HTTP_POST_FILES['gambarproduk']['name']; echo gambarproduk: $gambarprodukbr; echo berkasgambarproduk: $berkasgambarprodukbr; ? === This is the output in my Opera internet browser: === gambarproduk: /tmp/phppd6DZy berkasgambarproduk: === this is my php.ini: === ; File Uploads ; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = upload_tmp_dir = /srv/www/htdocs/tmpphp ; Maximum allowed size for uploaded files. upload_max_filesize = 100M === Please tell me, where is my mistake?. Thank you very much in advance. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] $HTTP_POST_FILES always produces empty value.
Dear my friends I don't understand why $HTTP_POST_FILES always produces empty value. This is my code === //cgi/cgiprodukcatalogadmin.php ?php $berkasgambarproduk=$HTTP_POST_FILES['gambarproduk']['name']; echo gambarproduk: $gambarprodukbr; echo berkasgambarproduk: $berkasgambarprodukbr; ? === This is the output in my Opera internet browser: === gambarproduk: /tmp/phppd6DZy berkasgambarproduk: === this is my php.ini: === ; File Uploads ; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = upload_tmp_dir = /srv/www/htdocs/tmpphp ; Maximum allowed size for uploaded files. upload_max_filesize = 100M === Please tell me, where is my mistake?. Thank you very much in advance. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $HTTP_POST_FILES always produces empty value.
Hi David, it's solved. Your advise solved my problem. Thank you very much. === On Mon, 30 Jul 2007 22:03:06 +0930 David Robley [EMAIL PROTECTED] wrote: Patrik Hasibuan wrote: Dear my friends I don't understand why $HTTP_POST_FILES always produces empty value. This is my code === //cgi/cgiprodukcatalogadmin.php ?php $berkasgambarproduk=$HTTP_POST_FILES['gambarproduk']['name']; echo gambarproduk: $gambarprodukbr; echo berkasgambarproduk: $berkasgambarprodukbr; ? === This is the output in my Opera internet browser: === gambarproduk: /tmp/phppd6DZy berkasgambarproduk: === this is my php.ini: === ; File Uploads ; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = upload_tmp_dir = /srv/www/htdocs/tmpphp ; Maximum allowed size for uploaded files. upload_max_filesize = 100M === Please tell me, where is my mistake?. Thank you very much in advance. Unless you are using an old version of php 4.1.0 you probably should use the $_FILES array instead of $_HTTP_POST_FILES Try that and see what happens. More info at http://php.net/file-upload if you need it. Cheers -- David Robley Oxymoron: Working Vacation. Today is Sweetmorn, the 65th day of Confusion in the YOLD 3173. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: $HTTP_POST_FILES always produces empty value.
Hi David, it's solved. Your advise solved my problem. Thank you very much. === On Mon, 30 Jul 2007 22:03:06 +0930 David Robley [EMAIL PROTECTED] wrote: Patrik Hasibuan wrote: Dear my friends I don't understand why $HTTP_POST_FILES always produces empty value. This is my code === //cgi/cgiprodukcatalogadmin.php ?php $berkasgambarproduk=$HTTP_POST_FILES['gambarproduk']['name']; echo gambarproduk: $gambarprodukbr; echo berkasgambarproduk: $berkasgambarprodukbr; ? === This is the output in my Opera internet browser: === gambarproduk: /tmp/phppd6DZy berkasgambarproduk: === this is my php.ini: === ; File Uploads ; ; Whether to allow HTTP file uploads. file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ;upload_tmp_dir = upload_tmp_dir = /srv/www/htdocs/tmpphp ; Maximum allowed size for uploaded files. upload_max_filesize = 100M === Please tell me, where is my mistake?. Thank you very much in advance. Unless you are using an old version of php 4.1.0 you probably should use the $_FILES array instead of $_HTTP_POST_FILES Try that and see what happens. More info at http://php.net/file-upload if you need it. Cheers -- David Robley Oxymoron: Working Vacation. Today is Sweetmorn, the 65th day of Confusion in the YOLD 3173. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] global variable does not exist anymore?
Hi Richard, You solved my problem. Thank you very...very much. === On Wed, 25 Jul 2007 23:54:37 +0100 Richard Davey [EMAIL PROTECTED] wrote: Hi Patrik, Wednesday, July 25, 2007, 11:30:56 PM, you wrote: Dear my friends... I create a very simple script in html and php as a first step. I use suse, apache2, mysql and php. I wonder why this script does not work: !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=ISO-8859-1 http-equiv=content-type titleGuru - Virtual bookstore who understands you for those want to be a GURU/title /head body Help us for statistic data collection for increasing our service by 'filling our guestbook'.br form action=cgi/cgibukutamu.php method=post table trtd align=rightName: /tdtd align=leftinput type=text name=tfnama/td/tr trtd align=rightLocation: /tdtd align=leftinput type=text name=tflokasi/td/tr trtd align=rightE-Mail: /tdtd align=leftinput type=text name=tfemail/td/tr trtd align=rightURL: /tdtd align=leftinput type=text name=tfurl/td/tr trtd align=rightComments: /tdtd align=leftinput type=text name=tfkomentar/td/tr trtd align=rightinput type=submit/tdtd align=leftinput type=reset/td/tr /table /form /body /html The value of tfnama is empty. cgi/cgibukutamu.php html table trtd/tdtd/td/tr trtd align=rightName/tdtd align=left?php echo $tfnama ?/td/tr /table /html I had a look the into the /etc/apache2 but I didn't find any global_variable switch as I used to find in httpd.conf suseonthelap:/etc/apache2 # grep -n -r global_variable ./* suseonthelap:/etc/apache2 # I got used to find global_variable=on line in the httpd.conf. Try looking in php.ini Then leave it disabled, and code your script properly so it checks the user input and validates it before using it. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] global variable does not exist anymore?
Dear my friends... I create a very simple script in html and php as a first step. I use suse, apache2, mysql and php. I wonder why this script does not work: !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html head meta content=text/html; charset=ISO-8859-1 http-equiv=content-type titleGuru - Virtual bookstore who understands you for those want to be a GURU/title /head body Help us for statistic data collection for increasing our service by 'filling our guestbook'.br form action=cgi/cgibukutamu.php method=post table trtd align=rightName: /tdtd align=leftinput type=text name=tfnama/td/tr trtd align=rightLocation: /tdtd align=leftinput type=text name=tflokasi/td/tr trtd align=rightE-Mail: /tdtd align=leftinput type=text name=tfemail/td/tr trtd align=rightURL: /tdtd align=leftinput type=text name=tfurl/td/tr trtd align=rightComments: /tdtd align=leftinput type=text name=tfkomentar/td/tr trtd align=rightinput type=submit/tdtd align=leftinput type=reset/td/tr /table /form /body /html The value of tfnama is empty. cgi/cgibukutamu.php html table trtd/tdtd/td/tr trtd align=rightName/tdtd align=left?php echo $tfnama ?/td/tr /table /html I had a look the into the /etc/apache2 but I didn't find any global_variable switch as I used to find in httpd.conf suseonthelap:/etc/apache2 # grep -n -r global_variable ./* suseonthelap:/etc/apache2 # I got used to find global_variable=on line in the httpd.conf. What should I do now? Please tell me. -- Patrik Hasibuan [EMAIL PROTECTED] Junior Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php