|
Posted by Jim Michaels on 02/23/06 01:51
"Tim Mickelson" <tim_mickelson@hotmail.com> wrote in message
news:th4zf.35560$av6.8679@tornado.fastwebnet.it...
> Hello everyone, I resolved it myself in the end, from the documentation of
> mysql_query:
> "The query string should not end with a semicolon"
> I never knew this, so I have always ended my queries with a semicolon,
> knowing this, it was sufficiento to do:
>
> <?
> $con = mysql_connect('localhost','pippo','pluto');
> mysql_select_db('test');
>
> // THIS WORKS :-)
> $query.= "CREATE PROCEDURE test.users(name VARCHAR(30)) ";
> $query.= "BEGIN";
> $query.= "DECLARE comment VARCHAR(100);";
> $query.= "SET comment = CONCAT(name,' is added');";
> $query.= "INSERT INTO users (id,name,comment) VALUES
> (NULL,name,comment);";
> $query.= "END";
>
> mysql_query($query);
> mysql_close($con);
> ?>
You are forgetting Aho's point. you are concatenating strings without
whitespace between them. so you end up with BEGINDECLARE as one word.
you could at least put a \n on those lines or a space.
Navigation:
[Reply to this message]
|