PHP ERRORS

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
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

PHP ERRORS

Post by Parody »

Is there an site somewhere that explains all the errors for php?

I really really would like one :D .
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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.
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post by Parody »

what does a T_STRING error mean?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post 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
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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();
  }
}
Parody
Forum Contributor
Posts: 252
Joined: Fri May 06, 2005 7:06 pm
Location: Great Britain

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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 ( )
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

and read up about quotes and concatenating strings and the like.
several errors in the code you posted.
Post Reply