Find the mistake PHP
- Losdivinos
- Posts: 139
- Joined: Tue Mar 01, 2011 5:44 pm
Find the mistake PHP
Hi.
I got this idea yesterday. This is mainly just for fun and for practice.
You will have to find the mistake in the PHP code above, and when that is done you should post a code with 1 mistake.
<?
include 'connect.php';
$getinfo="SELECT ALL FROM users WHERE userid='4' AND name='gaydyde'";
$getinfo2=mysql_query($getinfo) or die("Could not get gaydude's info!");
?>
Have fun!
I got this idea yesterday. This is mainly just for fun and for practice.
You will have to find the mistake in the PHP code above, and when that is done you should post a code with 1 mistake.
<?
include 'connect.php';
$getinfo="SELECT ALL FROM users WHERE userid='4' AND name='gaydyde'";
$getinfo2=mysql_query($getinfo) or die("Could not get gaydude's info!");
?>
Have fun!
Ask me anything about SEO & Marketing.
Skype: rasmus_355
Skype: rasmus_355
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Find the mistake PHP
ha this will drive my eyes nuts!
should be * not ALL, the gaydyde vs gaydude wont matter unless his name is suppose to be dude
how about some js my bullet code for checking collisions for asciiwars, means this is open book if you know what i mean, but the answer is easy...
should be * not ALL, the gaydyde vs gaydude wont matter unless his name is suppose to be dude
how about some js my bullet code for checking collisions for asciiwars, means this is open book if you know what i mean, but the answer is easy...
Code: Select all
if ((bullet[j].x > offsetmap + 485) || (bullet[j].y > 500) || (bullet[j].x < offsetmap + 5) || (bullet[j].y < 225))
{
bullet[j].destroy();
} // end if
for (k = 1; k < l; k++)
{
if (bullet[j].hasHit(goblin[k]))
{
bullet[j].destroy()
goblin[k].destroy();
spawn1curhp = spawn1curhp - 2;
spawn1GUI.resizeTo(spawn1curhp,10);
} // end if
}
}- Losdivinos
- Posts: 139
- Joined: Tue Mar 01, 2011 5:44 pm
Re: Find the mistake PHP
There is 1 more than needed of these! ----> }
<php
echo "<div><table><tr><td width='400 px'><b><h1>Accname</h1></b></td><td width='400 px'><b><h1>Clubname</h1></b></td></tr>";
$query = "SELECT * FROM msn";
$result = mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$accname = mysql_result($result,$i,"accname");
$vname = mysql_result($result,$i,"vname");
$vid = mysql_result($result,$i,"vid");
$i++;
echo "<tr><td><h2> " . $accname . "</h2></td><td><h2><a href='http://blabalbal.com/clubs/" . $vid . "'> " . $vname . "</a></h2></td></tr>";
}
?>
<php
echo "<div><table><tr><td width='400 px'><b><h1>Accname</h1></b></td><td width='400 px'><b><h1>Clubname</h1></b></td></tr>";
$query = "SELECT * FROM msn";
$result = mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$accname = mysql_result($result,$i,"accname");
$vname = mysql_result($result,$i,"vname");
$vid = mysql_result($result,$i,"vid");
$i++;
echo "<tr><td><h2> " . $accname . "</h2></td><td><h2><a href='http://blabalbal.com/clubs/" . $vid . "'> " . $vname . "</a></h2></td></tr>";
}
?>
Ask me anything about SEO & Marketing.
Skype: rasmus_355
Skype: rasmus_355
Re: Find the mistake PHP
I found 3! (there may be more):
- You didn't end your <table> tag
- It is supposed to be mysql_num_rows, instead of mysql_numrows
- The <a href> that you used near the end should have ' and ', not ' and "
<?php
$a = 5;
$b = 9;
$c = 3;
$d = 4;
if (($a + $b) = $c){
echo "L0lz, ! 0wn n00bz l!k3 !tz m4 j0b!";
}
elseif{
echo "!b0j 4m zt! 3k!l zb00n nw0 ! ,zl0L";
}
?>
*HINT* There are 2 total mistakes in this one
- You didn't end your <table> tag
- It is supposed to be mysql_num_rows, instead of mysql_numrows
- The <a href> that you used near the end should have ' and ', not ' and "
<?php
$a = 5;
$b = 9;
$c = 3;
$d = 4;
if (($a + $b) = $c){
echo "L0lz, ! 0wn n00bz l!k3 !tz m4 j0b!";
}
elseif{
echo "!b0j 4m zt! 3k!l zb00n nw0 ! ,zl0L";
}
?>
*HINT* There are 2 total mistakes in this one
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Re: Find the mistake PHP
you don't need an if in elseif{ and I don't think you need the parentheses around $a+$b
here is one
four errors in this one 
fixed an error XD
here is one
Code: Select all
class Code {
$languagename
}
function newLanguage($newname)
$this->languagename = $newname;
}
fixed an error XD
Re: Find the mistake PHP
- No semi colon ending,
- $this is not allowed in the function like that, so neither is languagename a valid argument.
- No opening bracket
Also, on the code for 92dude you forgot:
if (($a + $b) = $c)
The = operator is out of scope, it should have been ==. A single = means the sum of $a and $b is now $c, which in turn will throw an extra error since you cannot assign a $var to nothing.
Ok
There`s more then 1 error to be found, good luck 
- $this is not allowed in the function like that, so neither is languagename a valid argument.
- No opening bracket
Also, on the code for 92dude you forgot:
if (($a + $b) = $c)
The = operator is out of scope, it should have been ==. A single = means the sum of $a and $b is now $c, which in turn will throw an extra error since you cannot assign a $var to nothing.
Ok
Code: Select all
<?php
final class TestWorker implement Worker {
private static $workerThread = null;
function __construct(){
$this->workerThread = new Thread;
}
}
?>
Last edited by Xaleph on Fri Aug 12, 2011 6:17 pm, edited 1 time in total.
Re: Find the mistake PHP
The other error in mine wasn't the parenthesis, you need two = signs 
As for yours, I am not too great with JS (as you know XD)
But, I believe that there should be a ( before newLanguage and a ) before the final }
There should be a { at the end of the line with the function
and maybe it needs to be class.Code?
I'm not sure if even one of those are right
but, they are my four guesses!
OOPS, me and Xaleph uploaded at the same time, look at the errors he pointed out, not mine XD
As for yours, I am not too great with JS (as you know XD)
But, I believe that there should be a ( before newLanguage and a ) before the final }
There should be a { at the end of the line with the function
and maybe it needs to be class.Code?
I'm not sure if even one of those are right
OOPS, me and Xaleph uploaded at the same time, look at the errors he pointed out, not mine XD
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Re: Find the mistake PHP
i dont know a whole lot about OOP, but im guessing 'implement' should be 'extends'
either that or $this->workerThread = new Thread; should be $this->workerThread = new Thread(); as your declaring a new class?
enjoy :p
1 error (i think lol
)
either that or $this->workerThread = new Thread; should be $this->workerThread = new Thread(); as your declaring a new class?
Code: Select all
$query = "
SELECT
stats.*,
users.username AS username,
users.postcount AS postcount
FROM stats
LEFT JOIN (
SELECT
users.username AS username,
users.postcount AS postcount
) AS users ON stats.user_id = users.user_id
WHERE
stats.user_id = 4
LIMIT 1
";
enjoy :p
1 error (i think lol
New Site Coming Soon! Stay tuned 
Re: Find the mistake PHP
The FROM clause for users is missing.
On my code, there`s several things wrong.
Implement should have been implements ( extends is something different ) Implements means that a class is using an interface
The static $var is all cool, except in the code has no function whatsoever.
First of, the final prefix means no vars in the class can be changed on runtime in this case ( this can be modified obviously )
Also, even if the class was not final, you cannot access a static property by using $this, $this refers to 'that' object, yet static means it`s a class value, not an object value, so you cannot access a static value. To modify statics in an object you need to use the self keyword ( which refers to the class, not the object )
Anyway, in the code it wouldn`t matter since the class was final to begin with.
A more simple one:
Note: there are no errors to be found ( hopefully since it`s 3 am haha ) but the trick is to optimise the code
Good luck!
On my code, there`s several things wrong.
Implement should have been implements ( extends is something different ) Implements means that a class is using an interface
The static $var is all cool, except in the code has no function whatsoever.
First of, the final prefix means no vars in the class can be changed on runtime in this case ( this can be modified obviously )
Also, even if the class was not final, you cannot access a static property by using $this, $this refers to 'that' object, yet static means it`s a class value, not an object value, so you cannot access a static value. To modify statics in an object you need to use the self keyword ( which refers to the class, not the object )
Anyway, in the code it wouldn`t matter since the class was final to begin with.
A more simple one:
Code: Select all
function fibo($n){
if($n <= 2) return $n;
else
return fibo($n-2) + fibo($n - 1);
}
Re: Find the mistake PHP
I'm gonna guess that maybe you can change ($n-2) to ($n - 2)? I have no clue though, I've been sitting here for at least 5 minutes thinking of an algorithm that might simplify the math, but I've got nothing XD
Languages: C++, C#, Javascript + Angular, PHP
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny
Programs: Webstorm 2017, Notepad++, Photoshop
Current Project: HP Destiny