'Fatal error: Array callback has to contain indices 0 and 1
I am getting this error:
Fatal error: Array callback has to contain indices 0 and 1 in C:\xampp\htdocs\phpprojects\plapp\worker.php on line 53
How can I solve that problem? What's wrong with what I am doing here?
$results = mysql_query("SELECT asin_link FROM work WHERE email=$w_email");
while($row = mysql_fetch_array($result)) {
$work_link = $row['asin_link'];
echo '<a href="'.$work_link.'" target="'.$work_link.'">Visit Work link<br></a>';
echo '<form action="" method="post">
ASIN Number: <input type="text" name="asin"><br>
<input type="submit" value="Submit" name="submit">
</form>';}
if (isset($_POST['submit'])) {
$asin = $_POST('asin');
$qu ="INSERT INTO work (asin, email, asin_link) VALUES ('$asin', '$w_email','$work_link')";
if (mysql_query($qu)) {
echo "Your ASIN was received! Thanks";
}
}
Solution 1:[1]
change this
$asin = $_POST('asin');
to
$asin = $_POST['asin'];
Solution 2:[2]
It happens because your code tried to call an array as a function. (That's why the error calls it Array Callback)
I know it's really late for any answers on this, but for anyone else coming from Googling this error and seeking more info I post this example of alternative syntax, it seems to run PHP >= 7 :
<?php
class A {
static function ech($a) {echo $a;}
function echa($a) {echo $a;}
}
['A', 'ech']('Test');
[new A, 'echa']('Test');
Yes, it seems arrays can be called as functions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | AlexisAmasis |