andy_b_1502 Posted April 13, 2012 Share Posted April 13, 2012 Hi everyone, I have a display code to show my table contents. But... Theres an error right near the end. (i deleted it by mistake) could someone please tell me how i can fix this at all? <?PHP include ('db.php'); $query = "SELECT * FROM companies WHERE approved > 0"; $result = mysql_query($query); while ( $row = mysql_fetch_array($result, MYSQL_ASSOC )) { $approved = $row['approved']; SWITCH ($approved) { case 0: break; case 1: ?> <table border=1 cellpadding=1 cellspacing=2 bordercolor=#0066FF> <th>Company Name</th> <th>Contact Name:</th> <th>Contact Number:</th> <th>Contact Email:</th> <th>Address 1:</th> <th>Address 2:</th> <th>Area:</th> <th>Postcode:</th> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td><td></td><td></td><td></td></tr> <?PHP break; case 2: ?> <table width="500" height="308" border=0 cellpadding=1 cellspacing=2 bordercolor=#0066FF> <th width="65">Company Name</th> <th width="54">Contact Name:</th> <th width="57">Contact Number:</th> <th width="54">Contact Email:</th> <th width="57">Address 1:</th> <th width="57">Address 2:</th> <th width="36">Area:</th> <th width="63">Postcode:</th> <th width="403">Company Description:</th> <th width="65">Company Logo:</th> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> <?PHP break; case 3: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> </table> Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/ Share on other sites More sharing options...
batwimp Posted April 13, 2012 Share Posted April 13, 2012 What kind of problem is it? Is the table not displaying correctly? Is it showing any data from the variables at all? What do you remember about the error? Can you just re-load the page and get the error back? Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337046 Share on other sites More sharing options...
Muddy_Funster Posted April 13, 2012 Share Posted April 13, 2012 assides from some scary bad coding practice, what's the actual problem? Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337047 Share on other sites More sharing options...
andy_b_1502 Posted April 13, 2012 Author Share Posted April 13, 2012 this is the parse error message: "Parse error: syntax error, unexpected $end in /hermes/bosweb25a/b109/ipg.removalspacecom/index.php on line 145" Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337048 Share on other sites More sharing options...
batwimp Posted April 13, 2012 Share Posted April 13, 2012 You obviously didn't post all of your code, but you are probably missing a ; or } somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337049 Share on other sites More sharing options...
andy_b_1502 Posted April 13, 2012 Author Share Posted April 13, 2012 I posted all of the php coding. The full html/php code is this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> A:link {text-decoration:none;} A:visited {text-decoration:none; color:#999;} A:active { text-decoration: none; color:#FFF; } A:hover {text-decoration: none; color:#CCC;} </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Homepage | Removalspace.com</title> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <link href="styles/button-style.css" rel="stylesheet" type="text/css" /> <link href="newcss.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="adbar"><button><span><em>Advertise on Removalspace</em></span></button></div> <div id="global_wrapper"> <div id="header"></div> <div id="logo"></div> <div id="menu"><button><span><em>HOME</em></span></button> |<button><span><em>ADVERTISE</em></span></button>|<button><span><em>REMOVALS</em></span></button>|<button><span><em>STORAGE</em></span> </button> </div> <div id="searchbar"> <form method="get" action="search.php" style="background:url(images/adbar.jpg)"> <fieldset> <button><span><em>POSTCODE FROM</em></span></button> <input type="text" name="q" id="search-text" size="25" /> <button><span><em>POSTCODE TO</em></span></button> <input type="text" name="search-text" id="search-text2" size="25" /> <input type="submit" name="Submit2" value="go" /> </fieldset> </form></div> <div id="content"><?PHP include ('db.php'); $query = "SELECT * FROM companies WHERE approved > 0"; $result = mysql_query($query); while ( $row = mysql_fetch_array($result, MYSQL_ASSOC )) { $approved = $row['approved']; SWITCH ($approved) { case 0: break; case 1: ?> <table border=1 cellpadding=1 cellspacing=2 bordercolor=#0066FF> <th>Company Name</th> <th>Contact Name:</th> <th>Contact Number:</th> <th>Contact Email:</th> <th>Address 1:</th> <th>Address 2:</th> <th>Area:</th> <th>Postcode:</th> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td><td></td><td></td><td></td></tr> <?PHP break; case 2: ?> <table width="500" height="308" border=0 cellpadding=1 cellspacing=2 bordercolor=#0066FF> <th width="65">Company Name</th> <th width="54">Contact Name:</th> <th width="57">Contact Number:</th> <th width="54">Contact Email:</th> <th width="57">Address 1:</th> <th width="57">Address 2:</th> <th width="36">Area:</th> <th width="63">Postcode:</th> <th width="403">Company Description:</th> <th width="65">Company Logo:</th> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> <?PHP break; case 3: ?> <tr> <td><?PHP echo $row['company_name']; ?></td> <td><?PHP echo $row['contact_name']; ?></td> <td><?PHP echo $row['phone']; ?></td> <td><?PHP echo $row['email']; ?></td> <td><?PHP echo $row['street1']; ?></td> <td><?PHP echo $row['street2']; ?></td> <td><?PHP echo $row['location']; ?></td> <td><?PHP echo $row['postcode']; ?></td> <td><?PHP echo $row['basicpackage_description']; ?></td> <td><?PHP echo $row['premiumuser_description']; ?></td> <td><img src="images/thumbs/<?PHP echo $row['upload']; ?>" alt="logo"/></td> </tr> </table> </div> </div> <div id="footer"><button><span><em>www.removalspace.com</em></span></button></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337050 Share on other sites More sharing options...
batwimp Posted April 13, 2012 Share Posted April 13, 2012 Looks like you forgot to close your while() and your switch() blocks. Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337052 Share on other sites More sharing options...
andy_b_1502 Posted April 13, 2012 Author Share Posted April 13, 2012 i did? Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337055 Share on other sites More sharing options...
batwimp Posted April 13, 2012 Share Posted April 13, 2012 It looks like it. Do you have a text editor that shows you where your brackets mate up? Though I closed the blocks and it still gave me the error, so, hmmm.... Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337085 Share on other sites More sharing options...
MMDE Posted April 13, 2012 Share Posted April 13, 2012 Looks like you forgot to close your while() and your switch() blocks. Agreed. I put this at the very end of the file: <?php } } ?> And I only got include and mysql errors. Horrible code though. Quote Link to comment https://forums.phpfreaks.com/topic/260868-help-with-this-code/#findComment-1337090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.