115 pts.
 MySQLi and PHP problem with code
Can someone please tell me what I'm doing wrong with this particular line of code.
echo "<td colspan=3>{$Row['areaCode'] . '-' . $Row['prefix'] . '-' . $Row['lineNumber']}</td></tr>";
I know that the concatenation operator is the . 'areaCode' 'prefix' and 'lineNumber' are all fields in a table within an SQL database. any help would be appreciated. Thanks in advance.  Patricia

Software/Hardware used:
Windows XP Pro, CodeLobster for PHP; WAMP; MySQL
ASKED: March 30, 2010  10:02 PM
UPDATED: April 9, 2010  2:52 PM
  Help
 Approved Answer - Chosen by ITKE

Just in case someone else comes across this kind of problem in the future.

The code I finally figured out is

echo "<td colspan=3>({$Row['areaCode']}) {$Row['prefix']}-{$Row['lineNumber']}</td></tr>";

It will print out the phone number as follows:

(000) 000-0000

Works perfectly. Now to finish the rest of the project.

Thanks, Patricia

ANSWERED:  Mar 31, 2010  6:11 PM (GMT)  by ITKE

 
Other Answers:

Hi.

Parse error: parse error, expecting `’}” in C:\wamp\www\OswaltPatricia_Unit7Assignment\OswaltP_Connect.php on line 48

is the error message. Sorry, don’t know why I didn’t put that in. It also dawned on me that when I created the fields, each of the three fields had max values. areaCode has a max value of 3, same with prefix and the lineNumber has a max value of 4.

I’m not sure if that would make a difference or not when I’m simply trying to display the contents in a table.

Thanks, Patricia

Last Wiki Answer Submitted:  March 30, 2010  10:32 pm  by  PatOswalt   115 pts.
Latest Answer Wiki Contributors:  PatOswalt   115 pts.
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Patricia, what is the error message ?

 63,535 pts.

 

Hi.

Parse error: parse error, expecting `’}” in C:wampwwwOswaltPatricia_Unit7AssignmentOswaltP_Connect.php on line 48

is the error message. Sorry, don’t know why I didn’t put that in. It also dawned on me that when I created the fields, each of the three fields had max values. areaCode has a max value of 3, same with prefix and the lineNumber has a max value of 4.

I’m not sure if that would make a difference or not when I’m simply trying to display the contents in a table.

Thanks, Patricia

 115 pts.

 

This is cleaner

echo '<td colspan=3>(' . $Row['areaCode'] . ') ' . $Row['prefix'] . '-' . $Row['lineNumber'] . '</td></tr>';

or

<td colspan=3>(<?=$Row['areaCode']?>)<?=$Row['prefix']?>-<?=$Row['lineNumber']?></td></tr>
 20 pts.