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
for loop, string manipulation, '.=' acting weird
Old 03-17-2009, 08:21 AM for loop, string manipulation, '.=' acting weird
Extreme Talker

Posts: 177
Trades: 0
Heres my loop, should set something up like (#, #, #, #), ...(#, #, #, #),

But my output is #,#,#),#,#,#) .... #,#,#),

It's always missing the leader '('

PHP Code:
for($i 0$i 18$i++)
{
    
$queryValues .= '(' $cid ', ' $i+', ' $_POST['parOnHole'][$i] . ', '$_POST['distance'][$i] . '),';

I just can't grasp why it would behave like this.

I've tried using single quotes, double quotes, even adding obscene language in there, and nothing will display before the $cid part.

Any ideas?

Last edited by kbfirebreather; 03-17-2009 at 08:25 AM..
kbfirebreather is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-17-2009, 01:00 PM Re: for loop, string manipulation, '.=' acting weird
Extreme Talker

Posts: 177
Trades: 0
A co-worker helped me find the solution.

I was using the integers for strings incorrectly.

Updated code:
PHP Code:
for($i 0$i 18$i++)
{
    
$temp $i+1;
    
$queryValues .= "(" "$cid", " "$temp", " $_POST['parOnHole'][$i] . ", "$_POST['distance'][$i] . "),";

kbfirebreather is offline
Reply With Quote
View Public Profile
 
Old 03-18-2009, 02:08 AM Re: for loop, string manipulation, '.=' acting weird
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I believe you could just change $i+1 into ($i+1), so no need for the temp variable.
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 03-18-2009, 08:35 PM Re: for loop, string manipulation, '.=' acting weird
anderswc's Avatar
Super Talker

Posts: 132
Name: Will Anderson
Location: Terre Haute, IN
Trades: 0
Also, don't put $cid into a string like "$cid". Evaluating the string like that takes a whole lot more time.
__________________
Will Anderson

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
anderswc is offline
Reply With Quote
View Public Profile Visit anderswc's homepage!
 
Reply     « Reply to for loop, string manipulation, '.=' acting weird
 

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.55578 seconds with 12 queries