[PHP] Fatal Error: Function name must be a string

Pagina: 1
Acties:
  • 228 views sinds 30-01-2008
  • Reageer

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Rogier V
  • Registratie: Maart 2003
  • Laatst online: 07-09 06:49
Ik ben wat aan het spelen met PHP, maar ik krijg constant dezelfde foutmelding:
Fatal error: Function name must be a string in C:\xampp\htdocs\test\addtitle.php on line 16.
In phpMyAdmin heb ik al gecontroleerd of the veldtypes wel juist zijn. Via Google kwam ik een beschrijving van deze foutmelding tegen:
This error usually rears its ugly head when you are using variable functions. If you use a variable function and the variable you are using is unset, this error will result - I often get this when I am typing faster than I can think and I accidentally hit $ before a function name. PHP naturally interprets this is a variable-function call, and tries to look up the function name inside the variable.
Maar hier werd ik niet echt wijzer van.


PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<head>
<title>Add New Booktitle</title>
</head>

<body>
<?php
if (isset($_POST['add']))
{
include 'library/config.php';
include 'library/opendb.php';

$title = $_POST['title'];

$query = "INSERT INTO title (title) VALUES ('$title')";
$mysql_query($query) or die('Error, insert query failed');

include 'library/closedb.php';
echo "New Booktitle added";
}
else
{
?>
<form method="POST">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Title</td>
<td><input name="title" type="text" id="title"></td>
</tr>

<tr>
<td width="100">&nbsp;</td>
<td><input name="add" type="submit" id="add" value="Add New Book Title"></td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>

Acties:
  • 0 Henk 'm!

  • NLChris
  • Registratie: Juli 2004
  • Laatst online: 20-09 11:41
PHP:
16
mysql_query($query) or die('Error, insert query failed');


Normaal gesproken beginnen functies niet met een $, alleen variabelen.

(Uitzondering is als een variabele naar een functie verwijst)

:)

[ Voor 63% gewijzigd door NLChris op 10-08-2007 11:39 ]


Acties:
  • 0 Henk 'm!

  • Rogier V
  • Registratie: Maart 2003
  • Laatst online: 07-09 06:49
Oh, dit is wel erg stom van me 8)7 . Thanks voor je snelle reactie.

Acties:
  • 0 Henk 'm!

  • Onbekend
  • Registratie: Juni 2005
  • Laatst online: 23:19

Onbekend

...

Let er wel op dat iemand die addtitle.php uitvoert, jou hele tabel kan wissen d.m.v. MySQL injections in het "title"-vlak.

Speel ook Balls Connect en Repeat


Acties:
  • 0 Henk 'm!

  • Rogier V
  • Registratie: Maart 2003
  • Laatst online: 07-09 06:49
Klopt, ik ben gewoon aan het stoeien met PHP/MySQL. 't Is alweer een tijdje geleden ;). Maar bedankt voor de tip.