Parse errors
Code (php)
1
Parse error: syntax error, unexpected ',' in C:\web\apache\htdocs\tg\includes\p_functions.php on line 17
Functie(Die dus lijn 17 heeft)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
function KDsearch(){
if(isset($_POST['Submit_KDsearch']))
{
if($_POST['character'] != "")
{
$search_cid = $_SESSION['UPCID'];
$query = "SELECT Name, Level, Killcount, Deathcount FROM dbo.Character WHERE CID = '$search_cid'";
$query = mssql_query($query) or die('Error, query failed');
while( mssql_fetch_row($query) )
{
$kd = round(mssql_result($query, 3)/mssql_result($query, 4), 3);
$searchfin = "<tr>
<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>
</tr>", mssql_result($query, 1), mssql_result($query, 2), mssql_result($query, 3), mssql_result($query, 4), $kd);
return $searchfin;
}
}
}
}
?>
function KDsearch(){
if(isset($_POST['Submit_KDsearch']))
{
if($_POST['character'] != "")
{
$search_cid = $_SESSION['UPCID'];
$query = "SELECT Name, Level, Killcount, Deathcount FROM dbo.Character WHERE CID = '$search_cid'";
$query = mssql_query($query) or die('Error, query failed');
while( mssql_fetch_row($query) )
{
$kd = round(mssql_result($query, 3)/mssql_result($query, 4), 3);
$searchfin = "<tr>
<td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>
</tr>", mssql_result($query, 1), mssql_result($query, 2), mssql_result($query, 3), mssql_result($query, 4), $kd);
return $searchfin;
}
}
}
}
?>
specifieke lijn 17:
Code (php)
1
2
3
4
2
3
4
<?php
"
</tr>", mssql_result($query, 1), mssql_result($query, 2), mssql_result($query, 3), mssql_result($query, 4), $kd);
?>
"
</tr>", mssql_result($query, 1), mssql_result($query, 2), mssql_result($query, 3), mssql_result($query, 4), $kd);
?>
Gewijzigd op 01/01/1970 01:00:00 door Stefan
Trouwens, op line 17 staan allemaal komma's die unexpected(ONVERWACHTS!!!!) zijn...
Gewijzigd op 01/01/1970 01:00:00 door Timen kut
Wat doe ik fout.
hoe zou ik dat dan moeten oplossen, met die komma's?
www.php.net/array
meerdere dingen terug sturen vanuit een functie kan alleen met array's.
meerdere dingen terug sturen vanuit een functie kan alleen met array's.
Gewijzigd op 01/01/1970 01:00:00 door Timen kut
En hoe zou ik dit dan het beste in mijn script kunnen doen?
ik wil geen POST of $_SESSION in mijn functie hebben.
is alleen maar lastig als je de functie meerdere keren ga gebruiken.
Code (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
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
<?php
function KDsearch($search_cid){
$array = array();
$query = "SELECT Name, Level, Killcount, Deathcount FROM dbo.Character WHERE CID = '$search_cid'";
$query = mssql_query($query) or die('Error, query failed');
while($row = mssql_fetch_row($query) ){
$array[] = array("Name" => $row['Name'],
"Level" => $row['Level'],
"Killcount" => $row['Killcount'],
"Deathcount" => $row['Deathcount']);
}
return $array;
}
if(isset($_POST['Submit_KDsearch']))
{
if($_POST['character'] != "")
{
echo "<table border='1'>";
foreach (KDsearch($_SESSION['UPCID']) as $val){
echo "<tr><td>". $val['Name'] ."</td><td>". $val['Level'] ."</td><td>". $val['Killcount'] ."</td><td>". $val['Deathcount'] ."</td></tr>";
}
echo "</table>";
}
}
?>
function KDsearch($search_cid){
$array = array();
$query = "SELECT Name, Level, Killcount, Deathcount FROM dbo.Character WHERE CID = '$search_cid'";
$query = mssql_query($query) or die('Error, query failed');
while($row = mssql_fetch_row($query) ){
$array[] = array("Name" => $row['Name'],
"Level" => $row['Level'],
"Killcount" => $row['Killcount'],
"Deathcount" => $row['Deathcount']);
}
return $array;
}
if(isset($_POST['Submit_KDsearch']))
{
if($_POST['character'] != "")
{
echo "<table border='1'>";
foreach (KDsearch($_SESSION['UPCID']) as $val){
echo "<tr><td>". $val['Name'] ."</td><td>". $val['Level'] ."</td><td>". $val['Killcount'] ."</td><td>". $val['Deathcount'] ."</td></tr>";
}
echo "</table>";
}
}
?>
Gewijzigd op 01/01/1970 01:00:00 door johan
Dan moet je wel border gebruiken ipv botder ;)
Geef ik een voorbeeld doe ik het nog verkeerd
heb het aangepast Tx
Dankje!
____________
Oke, nu krijg ik undefined index errors:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Notice: Undefined index: Killcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 9
Notice: Undefined index: Killcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 11
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 13
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 15
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 18
Notice: Undefined index: Name in C:\web\apache\htdocs\tg\includes\p_functions.php on line 26
Notice: Undefined index: Level in C:\web\apache\htdocs\tg\includes\p_functions.php on line 27
Notice: Undefined index: Killcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 28
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 29
Notice: Undefined index: Killcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 11
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 13
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 15
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 18
Notice: Undefined index: Name in C:\web\apache\htdocs\tg\includes\p_functions.php on line 26
Notice: Undefined index: Level in C:\web\apache\htdocs\tg\includes\p_functions.php on line 27
Notice: Undefined index: Killcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 28
Notice: Undefined index: Deathcount in C:\web\apache\htdocs\tg\includes\p_functions.php on line 29
Dit is nu de uiteindelijke functie(Moet wel session gebruiken in de functie, want op de main page word die sessie niet gecreerd, die word pas gecreerd als een andere functie is gerund, die word gerund waneer de select box iets anders heeft geselecteerd.
Code (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
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
<?php
function KDsearch(){
global $_CONFIG;
$array = array();
$query = "SELECT Name, Level, Killcount, Deathcount FROM ".$_CONFIG['CharTable']." WHERE CID = '".$_SESSION['UPCID']."'";
$query = mssql_query($query) or die('Error, query failed');
while($row = mssql_fetch_row($query) ){
if($row['Killcount'] == 0 || $row['Killcount'] == "")
{
$row['Killcount'] == 0;
}
if($row['Deathcount'] == 0 || $row['Deathcount'] == "")
{
$row['Deathcount'] == 0;
}
if($row['Deathcount'] != 0 && $row['Killcount'] != 0)
{
$ratio = round($row['KillCount']/$row['Deathcount'], 3);
}
else
{
$ratio = "No Ratio";
}
$array[] = array("Name" => $row['Name'],
"Level" => $row['Level'],
"Killcount" => $row['Killcount'],
"Deathcount" => $row['Deathcount'],
"K/D Ratio" => $ratio);
}
return $array;
}
?>
function KDsearch(){
global $_CONFIG;
$array = array();
$query = "SELECT Name, Level, Killcount, Deathcount FROM ".$_CONFIG['CharTable']." WHERE CID = '".$_SESSION['UPCID']."'";
$query = mssql_query($query) or die('Error, query failed');
while($row = mssql_fetch_row($query) ){
if($row['Killcount'] == 0 || $row['Killcount'] == "")
{
$row['Killcount'] == 0;
}
if($row['Deathcount'] == 0 || $row['Deathcount'] == "")
{
$row['Deathcount'] == 0;
}
if($row['Deathcount'] != 0 && $row['Killcount'] != 0)
{
$ratio = round($row['KillCount']/$row['Deathcount'], 3);
}
else
{
$ratio = "No Ratio";
}
$array[] = array("Name" => $row['Name'],
"Level" => $row['Level'],
"Killcount" => $row['Killcount'],
"Deathcount" => $row['Deathcount'],
"K/D Ratio" => $ratio);
}
return $array;
}
?>
en dit gebruik ik dan in mijn page waar ik dus deze functie nodig heb:
Code (php)
Nvm, Opgelost & dingen geadd.
bleek dat mijn mssql rows returnde als $row[0], in plaats van $row['Name']
Gewijzigd op 01/01/1970 01:00:00 door Stefan
Waarom zet je in de mysql Default = 0 dat scheelt al een stuk code
En heb het al opgelost als je onder aan mijn laaste post kijkt.