DoctorX Posted June 27, 2009 Share Posted June 27, 2009 I am trying to creat a link for php in an application. I am very novus to php. goal is go get an ip address that is being collected in the DB and convert it in to a link to see how I can trace it on http://en.utrace.de/?query= here is the code that i have so far but i get an error on the page. <?php echo (<a href="http://en.utrace.de/?query="$result->fields['log_ip']> echo $result->fields['log_ip'] </a>); ?> i get the following error; Parse error: parse error, unexpected '<' in /home/web/pubht/_includes/admin/reports.php on line 298 Any help will be much appreciated. Thank you. MD X Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/ Share on other sites More sharing options...
Ken2k7 Posted June 27, 2009 Share Posted June 27, 2009 Put a double quote AFTER ( and another double quote BEFORE ). That should do it. But since echo is just a language construct and not a function, you don't need the parentheses. Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864438 Share on other sites More sharing options...
Philip Posted June 27, 2009 Share Posted June 27, 2009 You need to have quotes around the string: echo "<a href='http://en.utrace.de/?query={$result->fields['log_ip']}'>{$result->fields['log_ip']}</a>"; or echo '<a href="http://en.utrace.de/query=',$result->fields['log_ip'],'>',$result->fields['log_ip'],'</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864439 Share on other sites More sharing options...
SetToLoki Posted June 27, 2009 Share Posted June 27, 2009 <?php echo '<a href="http://en.utrace.de/?query="'.$result->fields['log_ip'].'>'.$result->fields['log_ip'].'</a>'; ?> your php was formatted wrong Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864440 Share on other sites More sharing options...
Ken2k7 Posted June 27, 2009 Share Posted June 27, 2009 You need to have quotes around the string: echo "<a href='http://en.utrace.de/?query={$result->fields['log_ip']}'>{$result->fields['log_ip']}</a>"; or echo '<a href="http://en.utrace.de/query=',$result->fields['log_ip'],'>',$result->fields['log_ip'],'</a>'; KingPhillip, any performance difference between using , and . in echos? PHP benchmark tests seems to favor dots more. What are your thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864443 Share on other sites More sharing options...
DoctorX Posted June 27, 2009 Author Share Posted June 27, 2009 WOW THAT WAS QUICK!!! Thanks a lot guys! another question, if i need this to be a pop-up window nad without any navigations optiions, any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864450 Share on other sites More sharing options...
SetToLoki Posted June 27, 2009 Share Posted June 27, 2009 WOW THAT WAS QUICK!!! Thanks a lot guys! another question, if i need this to be a pop-up window nad without any navigations optiions, any suggestions? yes use javascript a quick google search for javascript popup window tutorial/code will give you all the answers you need and allow you the ability to get it just how you want. Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864453 Share on other sites More sharing options...
Philip Posted June 27, 2009 Share Posted June 27, 2009 @SetToLoki - if you're talking to me you can use commas instead of dots. Echo allows for multiple parameters to be passed, so PHP won't have to concatenate the strings before outputting them... it just outputs the strings. @Ken - see above, and I do believe it is slightly (very very slightly) faster, just because it does not have to concatenate the strings first. Again, this is the same as the ' vs " argument. Speed wise, it is practically the same. @Doctor - as SetToLoki said, look into javascript's window open command: http://www.pageresource.com/jscript/jwinopen.htm Quote Link to comment https://forums.phpfreaks.com/topic/163832-php-link-question-please-help/#findComment-864497 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.