Pages

Search This Blog

Monday, July 13, 2009

#1064 - You have an error in your SQL syntax; xxx corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1

I try to create a mysql stored procedure using phpmyadmin and hit error below

Error

SQL query:

DELIMITER;

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1




my original code:

DELIMITER $$

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$
DELIMITER ;

try below steps, it help to solve my problem
1. Go to any SQL tab in phpMyAdmin.
2. Directly below the SQL text area you'll see a text input labeled "Delimiter." In that field, enter "$$".





3. Modify the script become like below

DROP PROCEDURE IF EXISTS `xxxweb`.`pp_pspbatch` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `pp_pspbatch`(
IN pBatchName VARCHAR(255),
IN pCountryID INT
)
BEGIN

xxxxx
xxxxx
xxxxx

END $$

and run it. It works.

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

this will happen in linux server when the owner permissions is set to read/write/execute only. There is no public and group permissions setting. To solve this, i can the permissions to 755.

Problem solved.

Thursday, July 2, 2009

Reverse 2 dimentional array in C/C++

I need to reverse 2 dimentional array in C/C++.
Example: i need to reverse
10010110 t0 01101001
10000000 to 00000001

my 2 dimention array:

myArray[0][0] = 1
myArray[0][1] = 0
myArray[0][2] = 0
myArray[0][3] = 1
myArray[0][4] = 0
myArray[0][5] = 1
myArray[0][6] = 1
myArray[0][7] = 0

myArray[1][0] = 1
myArray[1][1] = 0
myArray[1][2] = 0
myArray[1][3] = 0
myArray[1][4] = 0
myArray[1][5] = 0
myArray[1][6] = 0
myArray[1][7] = 0

//in main
void main()
{

//call function
reverseArray(myArray, 2);

}

// function reverseArray
void reverseArray(char array[][8], int row) {
int i;
int j;
int size;
char swap;

for (j = 0; j<=(row-1); j++)
{

i=0;
size = 8;

for(i;i<--size;i++)
{
swap=array[j][i];
array[j][i]=array[j][size];
array[j][size]=swap;
}
}
}

this return the value i need. Hope this help

Friday, June 5, 2009

PHP call external cgi and process responses

This is tough for me. First time to code in PHP with cgi and don't know how to start. Thanks google for this.

My task is call a cgi script to execute some function and process the return data. Well, here i'll mention on how to call external cgi and the process part can be settled using PHP string processing.

Let's start by example:

cgi domain location: www.xincube.com/script/handler/api.cgi

The code will strip header below and return the content of the response data.

HTTP/1.1 200 OK
Date: Sat, 06 Jun 2009 02:23:33 GMT
Server: Apache
Proxy-x-forwarded-for: 203.116.10.206
X-returncode: 0
X-returndesc: Access denied
Cache-control: no-cache
Pragma: no-cache
Connection: close
Transfer-Encoding: chunked
Content-Type: text/plain

We can do anything we want to get the information we need in $content.

CODE:

/* sample for calling cgi */
$host = 'www.xincube.com';
$path = '/scripts/handler/API.cgi';

$data_to_send = 'action=GetSupportedData';


PostToHost($host, $path, $data_to_send);

/* function that will call cgi */
function PostToHost($host, $path, $data_to_send) {

$header = "not yet";
$content = '';
$fp = fsockopen($host,80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)\n";
}
else {
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data_to_send);

while(!feof($fp)) {
//echo fgets($fp, 4000);
$line = fgets( $fp, 4000 );
if( $line == "\r\n" && $header == "not yet" ) {
$header = "passed";
}
if( $header == "passed" ) {
$content .= $line;
}
}
echo $content;
fclose($fp);
}
}


Hope this help. Support me to write more by clicking on the ads sponsor or donation. Thanks

Tuesday, May 19, 2009

MySql.Data.MySqlClient.MySqlException: Table 'xxx.xx_XxxxXxx' doesn't exist

Hit error when try to connect to MySQL in Linux from ASP.NET in IIS6. Seriously, the table is 100% Exist in the database but i hit error below:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: MySql.Data.MySqlClient.MySqlException: Table 'xxx. xx_XxxxXxx' doesn't exist




Well, finally find out that it caused by case sensitive on the table name. After i've change the name, it's work perfectly.


Monday, May 18, 2009

Access denied for user 'xxxx'@'xxx.xxx.xxx.xxx' (using password: YES)

Well, my scenario is connecting my ASP.NET 2.0 apps from IIS6 (window 2003 server) to MySQL (Linux) using ADO.NET Connector.

Hit error message when try to connect:
Access denied for user 'userxxx'@'xxx.xxx.xxx.xxx' (using password: YES)



It's quite worry because this is first time trying to connect from a .net web application is IIS to MySQL in Linux.

Prior to that, privileges must be granted in MySQL.
______________________________________________
mysql> grant all privileges on *.* to 'userxxx'@'xxx.xxx.xxx.xxx'
identified by 'xxxpasswordxxx' with grant option;
Query OK, 0 rows affected (0.00 sec)
______________________________________________

Finally, found that it's my own mistake. I've put in the wrong username and password. Check your username and password seriously before the connection.

Saturday, May 16, 2009

Add more than one column to a table in MySQL

Sometimes we might need to add multiple column to a table in MySQL, sample below work perfectly

ALTER TABLE pp_batch_detail
ADD `user_id` int(10) unsigned default NULL,
ADD `user_name` varchar(255) default NULL,
ADD `date_request` datetime default NULL;

Friday, March 27, 2009

Earth Hour



I'm in.  Are you?

Believe it,  it's simple. Switch off your light at local time 8:30pm on Saturday 28 March wherever you are in every corner of the world. Bring awareness to people around us on how much we love our earth.

Friday, March 13, 2009

Resize Image in Crystal Report 9 Visual Studio 2005

Well, many may think or looking for resize image in Crystal Report 9. Here is some hints and code that may help. Hopefully you can understand after go thru simple sample code.

1 pixel should be equal to 15 twips in Crystal Report.

int LogoWidth = 100;

      int LogoHeight = 80;

reportdocument.Load("abc.rpt");

reportdocument.SetDataSource(myDataTable);

reportdocument.Section2.ReportObjects["LogoImage1"].Width = LogoWidth * 15;

reportdocument.Section2.ReportObjects["LogoImage1"].Height = LogoHeight * 15;

CrystalReportViewer.ReportSource = reportdocument;

Sunday, March 1, 2009

JFolder::folder: Path is not a folder - AllVideos Reloaded in Joomla

In my local development machine, facing error after install AllVideos Reloaded in Joomla! 1.5.9

JFolder::folder: Path is not a folder
JFolder::files: Path is not a folder
JFolder::files: Path is not a folder

suspect is folder missing when AllVideos check on the playlist. The problem solve when i add a new folder manually to the folder videos to the playlist pointed folder. 

In my case, C:\xampp\htdocs\Joomla\images\stories\videos 

Hope this help you.

ps: it actually stated very clear that we need to create folder audio and videos in images/stories folder after the installation of AllVideos. It just that i didnt noticed.