Home about IT Motivation Course Sales Project About Me
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Saturday, March 08, 2014

PHPMAKER - ORACLE: ORA-01005: null password given; logon denied

error message: " ORA-01005: null password given; logon denied" when create view at phpmaker and no display pop up when generated file success.

environment:
  • database: oracle
  • front end: phpmaker

setting database in phpmaker ok but error when create VIEW

please checked below:
  • make sure netconfig setting at oracle successcfull login
  • make sure ODBC setting to database successfully login 
  • going to php.ini then make sure "extension=php_oci8.dll" unremark




Monday, June 11, 2012

timezone mysql & PHP not correct

To see what timezone your MySQL session is using, just execute this:
SELECT @@global.time_zone, @@session.time_zone;

to changes timezone, run below script: use super previlage
mysql> SET GLOBAL time_zone = 'America/New_York';
 or 
mysql> SET GLOBAL time_zone = 'Asia/Krasnoyarsk'; 
 
to check your date correct, use this:
select date(now());
or 
select curdate();
 
for php, please go to php.ini then edit below:
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "America/Los_Angeles"

; http://php.net/date.default-latitude
;date.default_latitude = 31.7667 
 
changes : America/Los_Angeles --> Asia/Seoul 
 

 


Sunday, July 17, 2011

How to turn off error reporting in php

If you want to turn off any errors and warning from displaying in the web page, The easiest way is to modify the php.ini file. But what if you want to turn off error reporting in php using your php code? you can accomplish this easily using php built in function error_reporting()

<?php
error_reporting(0); // Turn off all error reporting
?>
or

ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);


or

error_reporting (E_ALL ^ E_NOTICE);


or at php ini, un remark below script
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

Monday, March 21, 2011

error message "Use of undefined constant" and " Function session_is_registered() is deprecated "



if you got error message when run PHP applications below
"Use of undefined constant " .....

please set as below at php.ini


error_reporting = E_ALL & ~E_NOTICE

then if you got error as below
"Deprecated: Function session_is_registered() is deprecated "

the issue due to you use different version of PHP
please set as below at php.ini

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

don't forget to restart Apache after changes php.ini !

Saturday, August 21, 2010

remote IP at access log apache seen as 0.0.0.0

happen at Apache ver 2.2 on windows 2000 proffesional sp4.

According to Apache documentation, AcceptEx() is a Microsoft WinSock v2 API that provides some performance improvements over the use of the BSD style accept() API in certain circumstances. Some popular Windows products, typically virus scanning or virtual private network packages, have bugs that interfere with the proper operation of AcceptEx().

The resolution to the above problem is to disable the use of AcceptEx by using Win32DisableAcceptEx directive. Win32DisableAcceptEx only available in Apache version 2.0.49 and later version though.

Win32DisableAcceptEx directive should be place in httpd.conf configuration file. If you are using distribution from apachefriend’s xampp, the directive should be placed at httpd.conf file too, and not the httpd-mpm configuration file. The directive can be placed together with the line of #EnableMMAP off and #EnableSendfile off in httpd.conf.

If you still facing issue after enable the Win32DisableAcceptEx directive, try to uncomment (disable) the EnableMMAP and EnableSendfile directive. The line should looks like this:

EnableMMAP off
EnableSendfile off
Win32DisableAcceptEx

Note: I found that enable Win32DisableAcceptEx directive cause Apache running on Windows XP to crash frequently. So it’s possibe to try to just turn off (uncomment) EnableMMAP and EnableSendfile without Win32DisableAcceptEx for stability issue, although it doesn’t guarantee reliability of Apache web server.

Sunday, January 24, 2010

include_path in php.ini

the purpose for changes location folder path to certain path. default is dissable. Please set open the remark as below at php ini:
;;;;;;;;;;;;;;;;;;;;;;;;;; Paths and Directories ;;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2";include_path = ".:/php/includes";; Windows: "\path1;\path2"
include_path = ".;c:\AppServ\php5\pear"

then please copy folder jpgraph, fpdf, adodb , etc to that path
then restart the apache services

Fatal error: Call to undefined function mssql_connect()

Got error messsage Fatal error: Call to undefined function mssql_connect() in C:\AppServ\www .. when perform PHP use MsSQL server 2005, and Appsrv. Whereas below code at php.in already unremark
extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll
and Apache services already restart, PC also.
and below dll files also keep at C:\AppServ\php5\ext:
- php_msql.dll and
- php_mssql.dll

please download ntwdblib.dll at http://webzila.com/?wz=dll#results then restore to folder:
C:\AppServ\Apache2.2\bin then restart the apache services

Sunday, January 03, 2010

Buat report di PHP

ada banyak macamnya :
(1) pakai class fpdf (http://www.fpdf.org)

(2) pakai class tcpdf (http://www.tcpdf.org)

(3) pakai crystalreport

(4) pakai html2pdf (http://html2fpdf.sourceforge.net)
Sepertinya pake html2pdf tidak bisa untuk report repot yang model invoice, yang memerlukan header dan footer dan summary total amount di halaman terakhir.

Sunday, November 29, 2009

XAMMP: variabel $ form tidak bekerja

Berikut php scrip tidak bekerja bila memakai Xammp tapi ok bila memakai Appsvr:

<?
//dataform.php
if($submit)
{
echo"bilangan A adalah : ".$a;
echo"<br>bilangan B adalah : ".$b;
echo"<br>jumlah A + B adalah : ".($a+$b);
echo"<br>hasil kali A * B adalah : ".$a*$b;
}
?>
<form method="POST" action="dataformku.php">
<p>Input A:<input type="text" name="a" size="14"></p>
<p>Input B:<input type="text" name="b" size="14"></p>
<p><input type="submit" value="Hitung" name="submit"></p>

Penyebab :
- karena default setting register_globals di Xammp adalah Off , lihat setting dengan phpinfo.php
- pleasse go to C:\xampp\apache\bin\php.ini
dan set register_globals = On
- restart Apache and try gain

Sunday, July 26, 2009

C3 BARCODE LABEL - JEITA FORMAT 4f programming


below steps that you can use to develop printing Barcode label use format C3 JEITA 4f ?
you can use : PHP 5 programming , APACHE web server and fpdf class.
The point programming as below:
  • require code39.php and $pdf->Code39($pdf->GetX()+1, $pdf->GetY(), "1P$pn1") for barcode font
  • $pdf = new FPDF('P', 'cm', 'A4') for paper size
  • for($i=1;$i<=$ctk1;$i++) {....} for looping label printing quantity
  • function SetCol($col) { $x=25+$col*87 ...} at code39.php to set margin each column label.
  • onKeyDown="if(event.keyCode==13) document.getElementById('ctk11').focus();" for setup enter and focus cursor
  • onKeypress="if(event.keyCode <> 57) event.returnValue = false;" for setup only type number
  • onclick="form.action='test1.php';form.submit();" for submit button
  • Highlight form element- © Dynamic Drive (www.dynamicdrive.com) to create highlight form element

Thursday, June 18, 2009

PHP: create pivot table use ADODB

<?

//includekan class addob

include('adodb/adodb.inc.php');
include "adodb/pivottable.inc.php";
$db = ADONewConnection("mysql");
$db->Connect('localhost','id','password','dbname') or die("COULD NOT SELECT DATABASE.<br>");

$sql = PivotTableSQL(
$db, # adodb connection
'berita b, kategori k', # tables
'pc_berita as PC_Name', # rows (multiple fields allowed)
'nama_berita', # column to pivot on
'b.nama_berita = k.nama_kategori and tgl_berita >= "2009-06-01"' # joins/where
);

$db->SetFetchMode(ADODB_FETCH_ASSOC);
//tampilin datanya (buat tabel)
$rs = $db->Execute($sql);
if ($rs) {
echo "<table border ='1'>";
echo "<tr>";
$head = $rs->fields;
foreach($head as $hcol=>$col)
echo "<th>".ucfirst($hcol)."</th>";

echo "</tr>";
while (!$rs->EOF) {
$row = $rs->fields;
echo "<tr>";
$x =0;
foreach($row as $head=>$col)
{

echo "<td>$col</td>";
$x++;

}
echo "</tr>";
$rs->MoveNext();
}
echo "</table>";
}
//tampilkan generate sql nya
//echo $sql;

?>

http://phplens.com/adodb/pivot.tables.html

Saturday, May 09, 2009

mysql_num_rows(): supplied argument is not a valid MySQL result resource in

if you have error message as above at your web php script, please add below script for know the cause of the error:

$tampil="select * from table ";
$hasil=mysql_query($tampil) or die (mysql_error());
$jumlah=mysql_num_rows($hasil);


Saturday, March 28, 2009

PHP: refresh page automatically

refresh halaman diri sendiri tiap 5 dtk.

<html>
<head>
<meta http-equiv="refresh" content="5; url=http://halaman web ini sendiri"/>
</head>
<body>
<img src="script grafik"/>
</body>
</html>

dari http://blog.rosihanari.net/

multiple submit

beri nama produk2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../../inetpub/wwwroot/anggunblog/style/main.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" name="form1" method="post" action="cek_produk2.php">

<SCRIPT LANGUAGE="JavaScript" SRC="/sspcp/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var cal = new CalendarPopup();
</script>




User Name: <SELECT NAME=produk1 >
<?
echo "<OPTION VALUE=0 SELECTED>-- Select User Name --";
include "koneksi_detik.php";
$tampil="SELECT * FROM muser ORDER BY name_muser";
$hasil=mysql_query($tampil);
while($data=mysql_fetch_array($hasil))
{
echo "<OPTION VALUE=$data[name_muser]>$data[name_muser] = $data[dept_muser]";
}
echo "</OPTION></SELECT> ";
?>




<p>PR Date:
<SCRIPT LANGUAGE="JavaScript" ID="js1">
var cal1 = new CalendarPopup();
</SCRIPT>
<!-- The next line prints out the source in this example page.
It should not be included when you actually use the calendar popup code -->
<SCRIPT LANGUAGE="JavaScript">writeSource("js1");</SCRIPT>
<INPUT TYPE="text" NAME="date1" VALUE="" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].date1,'anchor1','yyyy-MM-dd');
return false;" TITLE="cal1.select(document.forms[0].date1,'anchor1','MM/dd/yyyy');
return false;" NAME="anchor1" ID="anchor1">select</A>
format: yyyy-mm-dd</td>
</tr>

</p>



--No--|---------------Item---------------|---Qty/Unit---|-------------Purpose-------------


<p>...[1]...
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="30" maxlength="30" name="produk3[]" id="textfield" />
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="10" maxlength="10" name="produk4[]" id="textfield" />
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="30" maxlength="30" name="produk5[]" id="textfield" />
</p>

<p>...[2]...
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="30" maxlength="30" name="produk3[]" id="textfield" />
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="10" maxlength="10" name="produk4[]" id="textfield" />
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="30" maxlength="30" name="produk5[]" id="textfield" />
</p>

<p>...[3]...
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="30" maxlength="30" name="produk3[]" id="textfield" />
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="10" maxlength="10" name="produk4[]" id="textfield" />
<input style="background-color:#f1f1f1; border-color:#777777; type="text" size="30" maxlength="30" name="produk5[]" id="textfield" />
</p>

<p>
<input type="submit" name="button" id="button" value="Submit" />
</p>
</form>

</body>
</html>


beri nama cek_produk2.php

<?php
require_once('koneksi_detik.php');

$count=count($produk3);
$count=count($produk4);
$count=count($produk5);

for ($i = 0; $i < $count; $i++) {

$id3 = $_POST['produk3'][$i];
$id4 = $_POST['produk4'][$i];
$id5 = $_POST['produk5'][$i];

mysql_query("INSERT INTO t_pr (pr_id,pr_usr,pr_dt,pr_itm,pr_qty,pr_pps,pr_sts,pr_po) VALUES ('','$produk1','$date1','$id3','$id4','$id5','','')");
}
?>

Sunday, March 15, 2009

one page many submit button

below php script for create 2 button in one page:

<html>
<body>
<head>
<title>Submit Banyak2</title>
</head>
<body>
<form name="form1" method="post">

<input name="button1" type="submit" onclick="form.action='cekDaftar.php';form.submit();" />
<input name="button2" type="submit" onclick="form.action='daftar.php';form.submit();" />

</form>
</body>
</html>

Monday, March 09, 2009

PHP: print button to print report use FPDF on the MySQL database

below script for function print:

function print1()
{
var docForm = document.form1;
var po_no = docForm.po_no.value;
if (po_no == "")
{
alert ("You Must Select PO No !");
return false
}
else
{
if(confirm("Preview ?")) {
window.open("pr_pdf.php?po_no="+po_no,"",
"height=710,width=1020,menubar=no,scrollbars=no,status=no,toolbar=no,top=0,left=0");
}
}
}

below script at the FPDF:

<?php
require_once('fpdf.php');
require_once('koneksi.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->setFont('Helvetica','',10);

$exe1=mysql_query("select * from t_po , t_msup where po_sup = msup_abrv and po_no = '$po_no'");
$data1=mysql_fetch_array($exe1);
$pdf->Text(20, 32, $data1['msup_name']);
$pdf->Text(20, 36, $data1['msup_adrs1']);
$pdf->Text(20, 40, $data1['msup_adrs2']);
$pdf->Text(20, 44, $data1['msup_adrs3']);
$pdf->Text(20, 48, "telp:");
$pdf->Text(30, 48, $data1['msup_telp']);
$pdf->Text(20, 52, "fax:");
$pdf->Text(30, 52, $data1['msup_fax']);
$pdf->Text(160, 28, date("d-M-Y"));

$pdf->SetXY(20,80);
$exe=mysql_query("select po_item,po_qty,po_oum,po_cur,po_purprc,(po_qty*po_purprc)amount,po_no,po_desc from t_po where po_no = '$po_no' and po_dsc = '0'");

$i=1;
while ($data=mysql_fetch_array($exe)){

$pdf->setFont('Helvetica','',10);
$pdf->SetleftMargin(15);
$pdf->ln(0);
$pdf->Cell(9, 4, $i, 0, 0, 'L');
$pdf->Cell(78, 4, $data['po_item'], 0, 0, 'L');
$pdf->Cell(8, 4, $data['po_qty'], 0, 0, 'R');
$pdf->Cell(10, 4, $data['po_oum'], 0, 0, 'L');
$pdf->Cell(12, 4, $data['po_cur'], 0, 0, 'R');
$pdf->Cell(25, 4, number_format($data['po_purprc'],2,".",","), 0, 0, 'R');
$pdf->Cell(10, 4, $data['po_cur'], 0, 0, 'R');
$pdf->Cell(30, 4, number_format($data['amount'],2,".",","), 0, 0, 'R');

$pdf->Ln();
$pdf->Cell(9, 4,' ', 0, 0, 'L');
$pdf->Cell(70, 4, $data['po_desc'], 0, 0, 'L');
$pdf->Ln(6);
$i+=1;
$pdf->setFont('Helvetica','',12);
$pdf->Text(147,15,$data['po_no']);
}
$pdf->setFont('Helvetica','',10);
$pdf->Text(25, 235, "$NoteL");
$pdf->Text(117, 235, "$NoteR");
$pdf->Text(77, 283, "Mr. R");
$pdf->Text(107, 283, "Mr. Y");
$pdf->Text(156, 283, "Mr. H");
$pdf->setFont('Helvetica','B',10);

$pdf->SetleftMargin(25);
$exe3=mysql_query("SELECT * FROM t_po WHERE po_no = '$po_no' and po_dsc = '1'");
$data3=mysql_fetch_array($exe3);
$pdf->Cell(16, 6, $data3['po_item'], 0, 0, 'L');
$pdf->Cell(126, 6, $data3['po_cur'], 0, 0, 'R');
$pdf->Cell(30, 6, $data3['po_amt'], 0, 0, 'R');
$pdf->setFont('Helvetica','B',10);
$pdf->SetleftMargin(45);
$pdf->ln();
$pdf->Cell(150, 0, '', 1, 0, 'C');
$pdf->ln();
$pdf->Cell(50, 5, 'T O T A L A M O U N T', 0, 0, 'L');
$pdf->ln();

$exe2=mysql_query("SELECT sum(po_amt) FROM t_po WHERE po_no = '$po_no'");
$data2=mysql_fetch_array($exe2);
$pdf->Cell(152, -5,number_format($data2['sum(po_amt)'],2,".",","), 0, 0, 'R');
$pdf->Output();
?>

Please cek :
  • PHP 4 and PHP 5 different on decimal script. PHP5 need to writedown the format as below : $pdf->Cell(30, 4, number_format($data['amount'],2,".",","), 0, 0, 'R');

PHP: radio button on the new, edit and save within 1 pages

di bagian grid area untuk click mouse, tulis ini:

for (var I = 0; I < docForm1.po_dsc.length; I++) {
if (docForm1.po_dsc[I].value == '<?= $result[$i]["po_dsc"] ?>') {
docForm1.po_dsc[I].checked = 'true';
}
}

di bagian grid area tampilan tulis ini:

<td align="right" width="25" class="tf" ><? if($result[$i]["po_dsc"]=='0'){echo "No";}else{echo "Yes";}?></td>

dibagian entry data tulis ini:

<td class="nmf" style=" padding-left:20px;">PO DSC</td>
<td class="emf" style="padding-left:20px; font-size:9px;" ><font class="mf">Yes</font>
<input type="radio" name="po_dsc" value="1" onClick="agreesubmit(this)" />
&nbsp;&nbsp;&nbsp;&nbsp;
<font class="mf">No</font> <input type="radio" name="po_dsc" onClick="agreesubmit1(this)" value="0" ></td>
</td>

silakan di coba

Sunday, March 08, 2009

create report PHP - Crystal Report - PDF at Ms SQL Server

<?php
$myCrystal = new COM("CrystalRuntime.Application");// or die("Unable to create Application COM object");

$myReport =& $myCrystal->OpenReport(getcwd()."\\".$_GET["f"]);

$myDBSObj =& $myReport->Database;
$myOption =& $myReport->ExportOptions;
$myParams =& $myReport->ParameterFields;

$myDBSObj->LogOnServer("PDSODBC.DLL", "DSN name", "database name", "sa", "password");

$myOption->DestinationType = 1;
$myOption->FormatType = 31;

if (isset($_GET["p"]))
for ($i = 1; $i <= count($_GET["p"]); $i++) {
$myParam = $myParams->Item($i);
//echo $myParam->Name;
$myParam->AddCurrentValue($_GET["p"][$i]);
//echo $_GET["p"][$i];
//echo $myParam->IsCurrentValueSet;
//echo $myParam->Value;
}

$DiskFileName = getcwd()."\\".current(explode(".",$_GET["f"])).".pdf";
$myReport->ExportOptions->DiskFileName = $DiskFileName;

$myReport->Export(FALSE);

$strFile = file_get_contents($DiskFileName);
//unlink($DiskFileName);
$lenFile = strlen($strFile);

header("Content-type: application/pdf");
header("Content-Length: " . $lenFile);
header("Content-Disposition: inline; filename=".current(explode(".",$_GET["f"])).".pdf");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: public");

print($strFile);

?>

DSN --> setting at ODBC window and Crystal report setting. Please make sure that DSN name should be same between above script, DSN windows name and seeting DSN at Crystal Report.

Sunday, February 22, 2009

PHP connection script to database MSSQL-MYSQL

below script for connection PHP to database MSSQL Server 2005 and MYSQL , just changes the "s" to "y"

alert('DB Connection error!');");
mysql_select_db($sqlDb, $sqlCon);

/**
* Use to perform SELECT to MYSQL Server
*
* @param String $strQuery
* @return Array $sqlRow
*/
function singleSelect($strQuery) {
global $sqlCon;
$sqlRs = mysql_query($strQuery, $sqlCon);
$sqlRow = array();
$idx = 1;
while ($row = mysql_fetch_array($sqlRs)) {
$sqlRow[$idx++] = $row;
}
mysql_free_result($sqlRs);
return $sqlRow;
}

/**
* Use to perform SELECT to MYSQL Server
*
* @param Array $arrQuery
* @return Array $sqlRows
*/
function multiSelect($arrQuery) {
global $sqlCon;
$sqlRs = mysql_query(implode("\n", $arrQuery), $sqlCon);
$sqlRows = array();
$idx = 1;
$idxs = 1;
do {
$sqlRow = array();
while ($row = mysql_fetch_array($sqlRs)) {
$sqlRow[$idx++] = $row;
}
$sqlRows[$idxs++] = $sqlRow;
$idx = 1;
} while (mysql_next_result($sqlRs));
mysql_free_result($sqlRs);
return $sqlRows;
}

/**
* Use to perform INSERT, UPDATE, and DELETE to MYSQL Server
*
* @param String $strQuery
* @return Array $sqlRow
*/
function singleUpdate($strQuery) {
global $sqlCon;
mysql_query($strQuery, $sqlCon);
}

/**
* Use to perform INSERT, UPDATE, and DELETE to MYSQL Server
*
* @param Array $arrQuery
* @return Array $sqlRow
*/
function multiUpdate($arrQuery) {
global $sqlCon;
mysql_query(implode("\n", $arrQuery), $sqlCon);
}

?>

Sunday, February 01, 2009

menggabungkan beberapa grafik ke dalam 1 page

berikut cara menggabungkam beberapa grafik kedalam 1 halaman (page), biar mudah dilihat:

<h1>GRAPH IT ISSUE THIS MONTH</h1>
<img src="grafik1.php"> <br>
<img src="grafik2.php">
<img src="grafik3.php"></br>

grafik1.php dan seterusnya adalah scrip grafiknya.
please pakai jpgraph untuk membuat berbagai type grafik