Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP - Syntax passing record id

Posted on 2014-02-28
8
Medium Priority
?
502 Views
Last Modified: 2014-02-28
Learning PHP and I don't have problems with the difficult concepts but the syntax is the worst language I have dealt with.  I can't get the passing of the URL id code to pass the syntax test.  I'm sure it is easy for experienced PHP coders -  If you notice the image code on the last line - I went through the same thing getting it to pass the syntax test.  I am modifying a program with a feature I want from another program and they coded things differently.

Thanks

  echo '<tr>';
                echo '<td>' . $i . '</td>';
		echo '<td>' <a href='info.php?id=".$row['id']."'>".$row['lastname']."</a>'</td>';
                echo '<td>' . $row['lastname'] . '</td>';
                echo '<td>' . $row['firstname'] . '</td>';
                echo '<td>' . $row['email'] . '</td>';
                echo '<td>' . $row['phonenumber'] . '</td>';
		echo '<td> <img src="'. $row['s_img']. '" width="102" height="111"/></td>';

Open in new window

0
Comment
Question by:JohnMac328
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39895579
                echo '<tr>';
                echo '<td>' . $i . '</td>';
		echo '<td> <a href="info.php?id='.$row['id'].'">'.$row['lastname'].'</a></td>';
                echo '<td>' . $row['lastname'] . '</td>';
                echo '<td>' . $row['firstname'] . '</td>';
                echo '<td>' . $row['email'] . '</td>';
                echo '<td>' . $row['phonenumber'] . '</td>';
		echo '<td> <img src="'. $row['s_img']. '" width="102" height="111"/></td>';

Open in new window

0
 

Author Comment

by:JohnMac328
ID: 39895582
Thats my question - I can't fix the syntax error
0
 
LVL 58

Expert Comment

by:Gary
ID: 39895594
The code is fixed in that comment

Sometimes it makes more sense to drop out of the PHP parse and do it this way.

%>
                <tr>
                <td><?=$i?></td>
		<td> <a href="info.php?id=<?=$row['id']?>"><?=$row['lastname']?></a></td>
                <td><?=$row['lastname']?></td>
                <td><?=$row['firstname']?></td>
                <td><?=$row['email']?></td>
                <td><?=$row['phonenumber']?></td>
		<td> <img src="<?=$row['s_img']?>" width="102" height="111"/></td>

Open in new window


(This is assuming open_tag is enabled)
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:JohnMac328
ID: 39895612
I guess I better add more code since it is changing so much - so how would it work with all of this

 while ($row = mysql_fetch_array($sql)) {
                // Print out the contents of the entry 
				
				
                echo '<tr>';
                echo '<td>' . $i . '</td>';
		echo '<td>' <a href='info.php?id=".$row['id']."'>".$row['lastname']."</a>'</td>';
                echo '<td>' . $row['lastname'] . '</td>';
                echo '<td>' . $row['firstname'] . '</td>';
                echo '<td>' . $row['email'] . '</td>';
                echo '<td>' . $row['phonenumber'] . '</td>';
		echo '<td> <img src="'. $row['s_img']. '" width="102" height="111"/></td>';
                $i++;
            }
 } 
else 

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 39895636
while ($row = mysql_fetch_array($sql)) {
                // Print out the contents of the entry 
          	echo '<tr>';
                echo '<td>' . $i . '</td>';
		echo '<td><a href="info.php?id='.$row['id'].'">'.$row['lastname'].'</a></td>';
                echo '<td>' . $row['lastname'] . '</td>';
                echo '<td>' . $row['firstname'] . '</td>';
                echo '<td>' . $row['email'] . '</td>';
                echo '<td>' . $row['phonenumber'] . '</td>';
		echo '<td><img src="'. $row['s_img']. '" width="102" height="111"/></td>';
		echo '<tr>'; 
                $i++;
            }
 } 
else

Open in new window

0
 

Author Closing Comment

by:JohnMac328
ID: 39895656
Great thanks - Do you know of any good sites with examples of different PHP coding to decipher the syntax problem I am running into?
0
 
LVL 58

Expert Comment

by:Gary
ID: 39895681
php.net has samples for all its functions.
Your problem above is very, very common when dealing with apostrophes and speech marks, even I screw up with it sometimes.
0
 

Author Comment

by:JohnMac328
ID: 39895691
Thanks Cathal!
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question