SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: code error

  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    code error

    if i wrote
    Code PHP:
    echo $message[$i]
    it prints a the full message but if i made $messagem+=$message[$i]; it prints the $messagem 0
    Code PHP:
    for($i=0;$i<$c;$i++)
    	{
    	/*echo $name[$i];
    	echo "<br>";
    	echo $mail[$i];
    	echo "<br>";
    	echo $user[$i];
    	echo "<br>";*/
    	$message[$i]='<table border="0" width="400" cellspacing="0" 
    cellpadding="0" id="table1" align=center>
    		<tr>
    			<td width="138">Name :</td>
    			<td>' . $name[$i] . '</td>
    		</tr>
    		<tr>
    			<td height="22" width="138">E-mail :</td>
    			<td height="22">' . $mail[$i] . '</td>
    		</tr>
    		<tr>
    			<td width="138">Link To View Profile :</td>
    			<td>' . $user[$i] . '</td>
    		</tr><br>
    	</table>';
    	//echo "<br>";
    	$messagem+=$message[$i];
    	}
    echo $messagem; ----> error line

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are not adding numbers use concatenation symbol "."
    PHP Code:
    $messagem .= $message[$i]; 
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  3. #3
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    You should use concatenation, not addition:

    Code:
    $messagem .= $message[$i];
    This will concatenate the strings.

    Code:
    $messagem += $message[$i];
    This tries to add the strings together mathematically, which will usually result in a value of 0.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •