bchandel Posted August 20, 2009 Share Posted August 20, 2009 I am getting the following error message while running the following script. I want to find out what is wrong here and would appreciate if some one can fix it. Thank you very much in advance! Parse error: syntax error, unexpected ';' in /home/blphpind/public_html/try/script.php on line 30 And the line 30 is $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" ? "-"; The complete modified script is as under: <?php $db_connect = mysql_connect("xxx.com", "user", "password"); mysql_select_db("xxx", $db_connect) or die( "Unable to select database"); $query = "SELECT * FROM Directory"; $result = mysql_query($query); ?> <html> <head> <style type="text/css"> .custom {font-family: Arial, Helvetica, sans-serif; } </style> <head> <body> <h1><left>Search Results:</left></h1> <table border="1" width="100%" cellspacing="2" cellpadding="2"> <tr> <th class="custom">Name</th> <th class="custom">Last Name</th> <th class="custom">First Name</th> <th class="custom">Phone</th> <th class="custom">Mobile</th> <th class="custom">E-mail</th> <th class="custom">Web</th> <th class="custom">State</th> <th class="custom">Country</th> <th class="custom">Profile</th> </tr> <?php while($d = mysql_fetch_array($result)) { $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" ? "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" ? "-"; $d['Profile'] = $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" ? "-"; echo "<tr> <td class='custom'>{$d['Name']}</td> <td class='custom'>{$d['LastName']}</td> <td class='custom'>{$d['FirstName']}</td> <td class='custom'>{$d['Phone']}</td> <td class='custom'>{$d['Mobile']}</td> <td class='custom'>{$d['Email']}</td> <td class='custom'>{$d['Web']}</td> <td class='custom'>{$d['State']}</td> <td class='custom'>{$d['Country']}</td> <td class='custom'>{$d['Profile']}</td> </tr>"; } ?> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/ Share on other sites More sharing options...
HoTDaWg Posted August 20, 2009 Share Posted August 20, 2009 make sure you are using the code tags! change your line from: <?php $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" ? "-"; ?> to: <?php $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; ?> Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902309 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Thank you for your message. The code now look like this. still there is small mistake somewhere. see if you can figure out and correct it. Thank you, Bhugol <?php while($d = mysql_fetch_array($result)) { <?php $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; ?> <?php $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" : "-"; ?> <?php $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" : "-"; ?> and I am getting this error message: Parse error: syntax error, unexpected '<' in /home/blphpind/public_html/try/script.php on line 30 and line 30 is <?php $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; ?> Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902338 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 Why do you have <?php while($d = mysql_fetch_array($result)) { <?php $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; ?> I mean, you already have <?php I think your problem is your continuous <?php and ?>s Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902344 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Thank you for your meesage. I have revised it per your suggestion. Below is the complete revised code. I am stlll geting this error: Parse error: syntax error, unexpected '<' in /home/blphpind/public_html/try/script.php on line 30 and line 30 is d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; Full script code is below: <html> <head> <style type="text/css"> .custom {font-family: Arial, Helvetica, sans-serif; } </style> <head> <body> <h1><left>Search Results:</left></h1> <table border="1" width="100%" cellspacing="2" cellpadding="2"> <tr> <th class="custom">Name</th> <th class="custom">Last Name</th> <th class="custom">First Name</th> <th class="custom">Phone</th> <th class="custom">Mobile</th> <th class="custom">E-mail</th> <th class="custom">Web Site</th> <th class="custom">State</th> <th class="custom">Country</th> <th class="custom">Profile</th> </tr> <?php while($d = mysql_fetch_array($result)) { $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" : "-"; ?> echo "<tr> <td class='custom'>{$d['Name']}</td> <td class='custom'>{$d['LastName']}</td> <td class='custom'>{$d['FirstName']}</td> <td class='custom'>{$d['Phone']}</td> <td class='custom'>{$d['Mobile']}</td> <td class='custom'>{$d['Email']}</td> <td class='custom'>{$d['Web']}</td> <td class='custom'>{$d['State']}</td> <td class='custom'>{$d['Country']}</td> <td class='custom'>{$d['Profile']}</td> </tr>"; } ?> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902354 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 Are you sure that's line 30? When I went to like 30 I got <td class='custom'>{$d['Name']}</td> Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902356 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 Try this anyway <html> <head> <style type="text/css"> .custom {font-family: Arial, Helvetica, sans-serif; } </style> <head> <body> <h1><left>Search Results:</left></h1> <table border="1" width="100%" cellspacing="2" cellpadding="2"> <tr> <th class="custom">Name</th> <th class="custom">Last Name</th> <th class="custom">First Name</th> <th class="custom">Phone</th> <th class="custom">Mobile</th> <th class="custom">E-mail</th> <th class="custom">Web Site</th> <th class="custom">State</th> <th class="custom">Country</th> <th class="custom">Profile</th> </tr> <?php while($d = mysql_fetch_array($result)) { $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" : "-"; echo "<tr> <td class='custom'>{$d['Name']}</td> <td class='custom'>{$d['LastName']}</td> <td class='custom'>{$d['FirstName']}</td> <td class='custom'>{$d['Phone']}</td> <td class='custom'>{$d['Mobile']}</td> <td class='custom'>{$d['Email']}</td> <td class='custom'>{$d['Web']}</td> <td class='custom'>{$d['State']}</td> <td class='custom'>{$d['Country']}</td> <td class='custom'>{$d['Profile']}</td> </tr>"; } ?> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902358 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Thank you for your help. I loaded the script. See display by visiting http://www.chandel.com/try/script.php The data is in wrong columns and long URLs are there as well. But seems close to success. may need to move things around. Is there any other way to achieve the same results? Thank you, Bhugol Chandel Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902360 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" : "-"; Look, you have to close the href on your web and profile Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902364 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 How to close and where to close? What would be the correct format for: d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" : "-"; Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902366 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 Try looking at your page in Chrome, it'll help. I'll show you $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}</a>" : "-"; I put blue to show you what's being considered the URL. Put a ' after {$d['Web']} and {$d['Profile']} Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902367 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Put ' at the very end of {$d['Web']}' and {$d['Profile']}' . Checked in Chrome. Now the E-mail, Web and profile hyperlink are missing. Need to try may be one last time. Coming close to victory. $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}>{$d['Web']}'</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}>{$d['Profile']}'</a>" : "-"; Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902370 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 Put this in, it'll work $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}'>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}'>{$d['Profile']}</a>" : "-"; You were meant to put it in at href='{$d['Web']} not at >{$d['Web']}</a> The code above should work Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902373 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Thank you. It made it lot better. Check it at http://chandel.com/try/script.php The only problem is these long URLs. It should only read Email, Web and Profile which is not happening. See what else left to be fixed below: $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>{$d['Email']}</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}'>{$d['Web']}</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}'>{$d['Profile']}</a>" : "-"; Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902377 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 What do you want done with those URL's? What should it show? It's just showing exactly what it's told to Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902379 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Instead for long URL in Email, Website, and Profile fields it shoud read say Send E-mail, Website, View Profile. Don't want Long URLS It will be something like in this format <a href="http://www.chandel.com">Go to Website</a></p> I hope I am able to make it clear. Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902385 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 I'm sorry, but do you know much about PHP at all? Try this $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>Email</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}'>Website</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}'>Profile</a>" : "-"; All I did was replace the variables from the link text with constant strings Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902387 Share on other sites More sharing options...
bchandel Posted August 20, 2009 Author Share Posted August 20, 2009 Finally I got this figured out. Here what I did. It is working fine now. I really appreciate your help and patience. Do you work on projects? let me know. I still have to fix few things like table look and to avoid cells without data to merge. Thank you again very much. People like you make this world wonderful. $d['Email'] = $d['Email'] ? "<a href='mailto:{$d['Email']}'>E-mail</a>" : "-"; $d['Web'] = $d['Web'] ? "<a href='{$d['Web']}'>Web Site</a>" : "-"; $d['Profile']= $d['Profile'] ? "<a href='{$d['Profile']}'>Profile</a>" : "-"; Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902395 Share on other sites More sharing options...
Garethp Posted August 20, 2009 Share Posted August 20, 2009 I do work on projects, my email is [email protected] if you want. By the way, if you have cells with no data, use this (as normal HTML, not a PHP variable) as a placeholder in the cell Link to comment https://forums.phpfreaks.com/topic/171094-solved-need-help-fixing-script-what-is-wrong-here/#findComment-902404 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.