error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kkr653
Forum Newbie
Posts: 2
Joined: Mon Jan 16, 2012 7:50 am

error

Post by kkr653 »

hello i have run the following code
but it gives error mesage

Fatal error: Cannot pass parameter 1 by reference in F:\wamp\www\dddddddddd\worddd.php on line 13

code is

<?php
// starting word
$word = new COM("word.application") or die("Unable to instantiate Word");
echo "Loaded Word, version {$word->Version}\n";

//bring it to front
$word->Visible = 1;

//open an empty document
$word->Documents->Add();

//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("anp.doc");

//closing word
$word->Quit();

//free the object
$word = null;
?>
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: error

Post by twinedev »

Not sure here, but i know that where I used to work, when one of the servers was upgraded to a new version of PHP, we had to dump some older Joomla installs onto an older server because of changes in new version. Forget offhand what version and/or what it was causing this, but that would be my guess that if you are using code from a tutorial somewhere and you are getting this, that the tutorial was written for an older version of PHP.

The issue is that it is expecting you to give something that can be referenced, (ie, a variable), not an actual literal value (the hard coded strings)

For your issue, I would try assigning "This is a test..." and "anp.doc" to variables, then use variables in the two lines where they are used. (not sure which one is line 13, so doesn't hurt to do it for both)

-Greg
Post Reply