By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

Trigger mit PHP-Script: DELIMITER-Problem

P: n/a
Hallo NG,

ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer
MySQL-Datenbank erstellt.

Doch leider funktioniert das nicht und ich habe auch über google keine
Hinweise gefunden. Ich vermute, dass es am Delimiter liegt.

Der Code, der per PHP abgeschickt wird:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;
Die Syntax ist laut MySQL-Doku [1] korrekt. Im phpMyAdmin wird der Code
(ohne die DELIMITER-Statements, aber mit Angabe dessen im entsprechenden
Feld) auch angenommen.
Versionen:
PHP 5.2
MySQL 5.0.32
Weiß jemand Rat?

Danke!

Gruß...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html
--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 20 '08 #1
Share this Question
Share on Google+
11 Replies


P: n/a
"Jensen Somers" <je****@sig.see.invalidschrieb im Newsbeitrag
news:O9******************************@giganews.com ...
Sven Reuter wrote:

<snip>

This is an English newsgroup, please post your question in English or
in
a newsgroup that targets your language.
Sorry for that. I worked all the day so that I didn't realized that :-(

Here an english version of my post:
I try to write a PHP script that should create a trigger in a MySQL
database.

But it don't work and I don't found hints at google. I assume a problem
with the DELIMITER.

Here's the Code sent by the PHP script:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;

The syntax correct according to MySQL-Doc [1]. In phpMyAdmin the code is
executed well (without DELIMITER statements but with delimiter
expression in the analogical form field).

versions:
PHP 5.2
MySQL 5.0.32
Can anyone help?

Thx!

Bye...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html
--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 20 '08 #2

P: n/a
Sven Reuter wrote:
Hallo NG,

ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in einer
MySQL-Datenbank erstellt.

Doch leider funktioniert das nicht und ich habe auch über google keine
Hinweise gefunden. Ich vermute, dass es am Delimiter liegt.

Der Code, der per PHP abgeschickt wird:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;
Die Syntax ist laut MySQL-Doku [1] korrekt. Im phpMyAdmin wird der Code
(ohne die DELIMITER-Statements, aber mit Angabe dessen im entsprechenden
Feld) auch angenommen.
Versionen:
PHP 5.2
MySQL 5.0.32
Weiß jemand Rat?

Danke!

Gruß...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html
This is an English newsgroup, and it's for PHP - not MySQL. Please ask
in a German MySQL newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 20 '08 #3

P: n/a
Jerry Stuckle wrote:
This is an English newsgroup, and it's for PHP - not MySQL. Please
ask in a German MySQL newsgroup.
I wrote my post in an english version again in reply to Jensens post.
I think it's not a problem of MySQL.

--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 20 '08 #4

P: n/a
Jerry Stuckle wrote:
Sven Reuter wrote:
>Hallo NG,

ich versuche gerade ein PHP-Script zu bauen, das einen Trigger in
einer MySQL-Datenbank erstellt.

Doch leider funktioniert das nicht und ich habe auch über google keine
Hinweise gefunden. Ich vermute, dass es am Delimiter liegt.

Der Code, der per PHP abgeschickt wird:

DELIMITER |
CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON anbieter
FOR EACH ROW BEGIN
DELETE FROM ext4cSupportform WHERE anbieter = OLD.anbieter;
END;
|
DELIMITER ;
Die Syntax ist laut MySQL-Doku [1] korrekt. Im phpMyAdmin wird der
Code (ohne die DELIMITER-Statements, aber mit Angabe dessen im
entsprechenden Feld) auch angenommen.
Versionen:
PHP 5.2
MySQL 5.0.32
Weiß jemand Rat?

Danke!

Gruß...Sven.

[1] http://dev.mysql.com/doc/refman/5.1/...e-trigger.html

This is an English newsgroup, and it's for PHP - not MySQL. Please ask
in a German MySQL newsgroup.
Is it?

By golly, and there was me thinking it was a worldwide group.

Aug 20 '08 #5

P: n/a
Sven Reuter wrote:
Jerry Stuckle wrote:
>This is an English newsgroup, and it's for PHP - not MySQL. Please
ask in a German MySQL newsgroup.

I wrote my post in an english version again in reply to Jensens post.
I think it's not a problem of MySQL.
You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 20 '08 #6

P: n/a
Jerry Stuckle wrote:
Sven Reuter wrote:
>Jerry Stuckle wrote:
>>This is an English newsgroup, and it's for PHP - not MySQL. Please
ask in a German MySQL newsgroup.

I wrote my post in an english version again in reply to Jensens post.
I think it's not a problem of MySQL.

You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..

Things to check.

- PHP user has sufficient privileges to access the database in this way:
the phpmyadmin program my not connect to the database as the same user.

- no hidden charcter replacement to the query string is being performed
my the php->mysql shim library.

turn on all error reporting a well.
Aug 20 '08 #7

P: n/a
The Natural Philosopher wrote:
Jerry Stuckle wrote:
>You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..
Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it worked
(encapsulated in PHP code especially for Jerry ;-) ):

$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON
anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE anbieter
= OLD.anbieter; END;');

Bye...Sven.
--
http://www.sReuter.net/
http://www.Auskennbert.de/

Aug 21 '08 #8

P: n/a
Sven Reuter wrote:
The Natural Philosopher wrote:
>Jerry Stuckle wrote:
>>You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..

Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it worked
(encapsulated in PHP code especially for Jerry ;-) ):
`Be kind to Jerry. He's really past it these days..
$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON
anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE anbieter
= OLD.anbieter; END;');
Ee Bai Gum kad, that were a strangling of t'English language.
Bye...Sven.
Aug 21 '08 #9

P: n/a
Sven Reuter wrote:
The Natural Philosopher wrote:
>Jerry Stuckle wrote:
>>You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.
However the SQL code works, except when embedded into php..

Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it worked
(encapsulated in PHP code especially for Jerry ;-) ):

$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE ON
anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE anbieter
= OLD.anbieter; END;');

Bye...Sven.
Which is the answer you would have gotten very quickly had you asked in
the correct newsgroup.

This isn't a PHP issue - it's true when you create a trigger using ANY
language APIs. That includes C, Java and any other supported language,
not just PHP.

Here's a hint. PHP knows absolutely NOTHING about CREATE TRIGGER or
similar SQL statements. They're just strings to PHP - which are passed
on to MySQL for processing.

So maybe next time you'll ask in the correct newsgroup - and get an
answer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 21 '08 #10

P: n/a
Jerry Stuckle wrote:
Sven Reuter wrote:
>The Natural Philosopher wrote:
>>Jerry Stuckle wrote:
You aren't showing any PHP code, and only asking about SQL code.

comp.databases.mysql is the correct group to be asking in.

However the SQL code works, except when embedded into php..

Yes, that's right. I think I've found a solution for my problem:

Although MySQL requires DELIMITER statements it's not possible to use
them in PHP. I've just sent the statement for the trigger and it
worked (encapsulated in PHP code especially for Jerry ;-) ):

$result = mysql_query('CREATE TRIGGER ext4cAnbieter_del AFTER DELETE
ON anbieter FOR EACH ROW BEGIN DELETE FROM ext4cSupportform WHERE
anbieter = OLD.anbieter; END;');

Bye...Sven.

Which is the answer you would have gotten very quickly had you asked in
the correct newsgroup.

This isn't a PHP issue - it's true when you create a trigger using ANY
language APIs. That includes C, Java and any other supported language,
not just PHP.

Here's a hint. PHP knows absolutely NOTHING about CREATE TRIGGER or
similar SQL statements. They're just strings to PHP - which are passed
on to MySQL for processing.

So maybe next time you'll ask in the correct newsgroup - and get an answer.
What part of 'bye' do you not understand?

Oh: comp.lang.english-for-dummies is over there ->
Aug 21 '08 #11

P: n/a
Message-ID: <12***************@proxy00.news.clara.netfrom The Natural
Philosopher contained the following:
>This is an English newsgroup, and it's for PHP - not MySQL. Please ask
in a German MySQL newsgroup.
Is it?

By golly, and there was me thinking it was a worldwide group.
It's an English language group, propagated worldwide.

--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011
http://slipperyhill.co.uk - http://4theweb.co.uk
Aug 26 '08 #12

This discussion thread is closed

Replies have been disabled for this discussion.