Jump to content

novice needs help - combining html & php


jackappleby

Recommended Posts

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

 

Getting this error with the following code...

 

<?
if($session->logged_in){




echo "	<a onmouseover=\"popup('click to edit')\" 
     	onmouseout=\"kill()\" 
     	title=\"\" 
     	onfocus=\"this.blur()\" 
     	href=\"#\">



		$data = mysql_query("SELECT * FROM headers")
		or die(mysql_error()); 

		$info = mysql_fetch_array( $data );

		Print "".$info['header_1'] .""; 



</a>

";}
?>

 

 

If a user is logged in, I want them to see the link. The text in the link is being pulled from a mysql database. There is no database connection problem. This is just a syntax problem, to do with the...

 

$data = mysql_query("SELECT * FROM headers")
		or die(mysql_error()); 

		$info = mysql_fetch_array( $data );

		Print "".$info['header_1'] .""; 

 

...part (I think). I am new to PHP and at the moment just copying and pasting and hoping, but not understanding. Can someone just re-jig the code so it displays the data in the databse as the link text? (I will not understand any jargon!).

 

Thanks a lot

Link to comment
https://forums.phpfreaks.com/topic/111329-novice-needs-help-combining-html-php/
Share on other sites

You didn't end the string in the echo statement. Since you're new, you really should try to understand what you're copying and pasting so you don't accidentally run some malicious code.

 

<?php
echo "	<a onmouseover=\"popup('click to edit')\" 
     	onmouseout=\"kill()\" 
     	title=\"\" 
     	onfocus=\"this.blur()\" 
     	href=\"#\">";
?>

 

Since I don't like to see so many escaped quotes, here's how I would write this:

<?php
echo '<a onmouseover="popup(' . "'click to edit'" . ')" onmouseout="kill()" title="" onfocus="this.blur()" href="#">';
?>

 

Much cleaner and easier to understand (IMHO).

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.