Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created November 26, 2011 04:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/1395043 to your computer and use it in GitHub Desktop.
Save iaindooley/1395043 to your computer and use it in GitHub Desktop.
Spaghetti Code
<?php
function getPageTitle()
{
return mysql_result('SELECT title FROM data',0,'title');
}
?>
<html>
<head>
<title><?php echo htmlentities(getPageTitle()); ?></title>
</head>
<body>
<?php if($_GET['some_parameter']) { ?>
<ul>
<?php
mysql_connect('localhost','user','pass');
mysql_select_db('database');
$query = mysql_query('SELECT * FROM table');
while($row = mysql_fetch_assoc($query))
{
?>
<li><?php echo htmlentities($row['some_field']); ?></li>
<?php } ?>
</ul>
<?php } ?>
</body>
</html>
@CitizenOfRome
Copy link

Perhaps this proves your point: You are missing a ?> in the title-tag ...

@iaindooley
Copy link
Author

Haha totally :)

@piccaso
Copy link

piccaso commented Apr 15, 2015

I don't think that this will work...
Calling getPageTitle (and mysql_result) before connecting to the database :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment