Fatal Error with Array

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
elitegoodguy
Forum Newbie
Posts: 9
Joined: Mon Oct 02, 2006 1:00 pm

Fatal Error with Array

Post by elitegoodguy »

I am trying to pass an array from a form on an application. but for some reason I am getting this error.
Fatal error: Function name must be a string in /var/www/specifier/adminaddproduct.php on line 74
This the PHP portion of my form.

Code: Select all

<?php 
// Sets the Database Settings
$table="projects";
// Connects to the MYSQL Database and Selects the right Table
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query="SELECT * FROM $table ORDER BY name ASC";
// Counts the number of entries in the Database
$result=mysql_query($query) or die(mysql_error());
$num=mysql_numrows($result);
mysql_close();
$i=0;
// Loops writing this the same number of times as entries
while ($i < $num)
{
	$name=mysql_result($result,$i,"name");
	$id222=mysql_result($result,$i,"Id");
	echo "<input type=checkbox name=proj[] value=$id222>$name<br>";
	$i++;
}
?>
And this is the PHP script it gets sent to.

Code: Select all

<? 
$array = $_POST('proj');
echo "You selected the following Project(s):<br>" ;
foreach ($array as $selected_proj) { 
echo $selected_proj."<br>";
}
?>
The Line 74 that the error message is referring to is:
$array = $_POST('proj');

Can someone help me figure out what I am doing wrong here?

Thanks
Chris
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_POST['proj'].
elitegoodguy
Forum Newbie
Posts: 9
Joined: Mon Oct 02, 2006 1:00 pm

Post by elitegoodguy »

feyd wrote:$_POST['proj'].
WOW I couldn't believe how simple that was... lol
I found a ton of tutorials and every one of them listed
$array = $_POST('proj');

thank you
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

elitegoodguy wrote:
feyd wrote:$_POST['proj'].
WOW I couldn't believe how simple that was... lol
I found a ton of tutorials and every one of them listed
$array = $_POST('proj');

thank you
a little off-topic.
could you give us a single tutorial that gives you the example with () instead of []
elitegoodguy
Forum Newbie
Posts: 9
Joined: Mon Oct 02, 2006 1:00 pm

Post by elitegoodguy »

jmut wrote:
elitegoodguy wrote:
feyd wrote:$_POST['proj'].
WOW I couldn't believe how simple that was... lol
I found a ton of tutorials and every one of them listed
$array = $_POST('proj');

thank you
a little off-topic.
could you give us a single tutorial that gives you the example with () instead of []
OHH My lol. I went back to those tutorials and low and behold it has the correct answer. And I could have sworn it was in the PHP & MySQL Blueprint book, But after looking there I see where it has the correct answer too. But in my defense the examples were either really small or had a wierd font :D I need to get my eyes checked lol


I guess spending all the time looking over each tutorial and in the book I must have missed the simple things

I'm sorry for any inconvenience this may have caused
Post Reply