Page 1 of 1

PHP ERRORS

Posted: Tue May 31, 2005 11:36 am
by Parody
Is there an site somewhere that explains all the errors for php?

I really really would like one :D .

Posted: Tue May 31, 2005 11:44 am
by JAM
'All' is a very loose term.
php.net's own is a good start, then just continue from there, by clicking the various links on the page aso aso.

Posted: Tue May 31, 2005 11:48 am
by Parody
what does a T_STRING error mean?

Posted: Tue May 31, 2005 12:21 pm
by JAM
'String Terminator' if i recall correctly.

Code: Select all

<?php
echo "foo';
echo "foo";
?>

Code: Select all

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in page.php on line 3
The error is seen happen in row 3, but exists earlier (here; line 2).

There are some more here but not all are included

Posted: Tue May 31, 2005 5:49 pm
by Parody
How do I write an IF statement that if something is true then it will perform an action, such as update something in a MYSQL database?

That is kinda my problem, because it automatically ends the line during the code it has to execute.

Posted: Tue May 31, 2005 6:00 pm
by timvw
you mean something like this?

Code: Select all

// she wants me to learn her to program :p
$tim_has_new_girlfriend = true;

if ($tim_has_new_girlfriend)
{
  $result = mysql_query("UPDATE chicks SET count=count+1");
  if ($result)
  {
    echo "Added 1 to the counter...";
  }
  else
  {
    echo "Something went wrong: " . mysql_error();
  }
}

Posted: Wed Jun 01, 2005 4:04 am
by Parody
What just happened? Sorry, that wasnt my intentional fault, wait a min

Code: Select all

if ($addtime > $crimetime2)
()
else
(
die "You still have "$difference" to go before you can do another crime";
$rand = rand(200,367);
mysql_connect("localhost", "admin", "ak7456";   
mysql_select_db ("stats")or die ("Could not select database");
$query = “SELECT  cstat FROM stats WHERE username=$_SESSION['username']”;
$result = mysql_query($query);
while ($row = mysql_fetch_array($result));
mysql_close();
$chancemoney = $row[‘cstat'] * 3;
$moneyget = $rand + $chancemoney;
$rand2 = rand(0,100);
$dvd = $row[‘cstat'] + 10;
)
if ( $dvd > $rand2 )
(
$success = 1;
)
else
(
$success = 0;
) 
switch ($success) {
case "0":
    print "You failed and were caught by the cops!";
    break;
case "1":
    print "You sold some DVDs and CDs and got /$"$moneyget"";
    break;			
  }
if ( $success == 1 )
(mysql_connect("localhost", "admin", "ak7456";   
mysql_select_db ("stats")or die ("Could not select database");
$money = “SELECT money FROM stats WHERE username=$_SESSION['username']”;
$result = mysql_query($query);
while ($row = mysql_fetch_array($result));
mysql_query($money);
)
:P

Posted: Wed Jun 01, 2005 4:09 am
by timvw
Please read the manual http://www.php.net/manual Chapter 16. Control Structures... It will save you and us a lot of time... While you are at it, notice that curly brackets { } are used and not ( )

Posted: Wed Jun 01, 2005 7:54 am
by phpScott
and read up about quotes and concatenating strings and the like.
several errors in the code you posted.