Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-24-2009, 09:43 AM spot the error
Experienced Talker

Posts: 41
Trades: 0
Code:
if ($data1 == 0) {                                    "$data1 = $buffer2[0]"};
if ($data2 == 0) {} elseif  ($data1 == [0]) { "$data2 = $buffer2[1]"};
if ($data3 == 0) {} elseif  ($data2 == [0]) { "$data3 = $buffer2[2]"};

its been a few hours of trying every combination of quotes and )( i dont see it
flatrat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-24-2009, 12:43 PM Re: spot the error
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
To begin with, you need to use spaces and tabs in your if statements:
PHP Code:
if(condition)
{
     
//code here
}
else if(
other condition)
{
     
//code here

What do you expect
PHP Code:
"$data1 = $buffer2[0]
to do? It looks like you are trying to perform an assignment, but there is no reason for there to be quotes. Also, each of those expressions must end with a semicolon.

Why do you have if statements with empty bodies (ie {} )? In the case above removing the else from the following elseif statement will have the same effect.

You don't need to end your if/elseif blocks with a semicolon. Individual expressions however must end with a semicolon.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-24-2009, 07:25 PM Re: spot the error
Skilled Talker

Posts: 54
Trades: 0
I would use a switch if I needed this done. (php.net)
KellyAX is offline
Reply With Quote
View Public Profile
 
Old 07-24-2009, 07:50 PM Re: spot the error
Novice Talker

Posts: 9
Trades: 0
There are a lot of errors here and i'm not sure what you're trying to do.

PHP Code:
<?php
    
if ($data1 == 0
{                                    
    
$data1 $buffer2[0];
}

if (
$data2 == 0
{
    
// do nothing
}
else if(
$data1 == 0

    
$data2 $buffer2[1];
}

if (
$data3 == 0
{
    
// do nothing

else if(
$data2 == 0

    
$data3 $buffer2[2];
}

?>
I had to rewrite the code to remove the syntax errors.

i wasn't really too sure what you wanted.. maybe if you explain what you want to do, i can be of more help.

Thanks
__________________

Please login or register to view this content. Registration is FREE

Free Pay Per Click for Webmasters
sc_king is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to spot the error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19088 seconds with 12 queries