# Why won't this work?

**URL:** <https://forum.kirupa.com/t/why-wont-this-work/176871>\
**Category:** Uncategorized\
**Created:** [January 27, 2006, 3:58pm UTC](https://forum.kirupa.com/t/why-wont-this-work/176871 "2006-01-27T15:58:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonahholliday](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jonahholliday/32/2097_2.png) [@jonahholliday](https://forum.kirupa.com/u/jonahholliday)\
**Post date:** [January 27, 2006, 3:58pm UTC](https://forum.kirupa.com/t/why-wont-this-work/176871/1 "2006-01-27T15:58:31Z")

</div>

Here’s the code…  
[INDENT][SIZE=1][COLOR=RoyalBlue]\<?php[/COLOR][/SIZE]

[SIZE=1][COLOR=RoyalBlue]if(isset($\_POST[‘save’]))[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]{[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] $sitename = $\_POST[‘sitename’];[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] if(!get\_magic\_quotes\_gpc())[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] {[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] $sitename = addslashes($sitename);[/COLOR][/SIZE]

[SIZE=1][COLOR=RoyalBlue] }[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]include(“config.inc.php”);[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]$dbh=mysql\_connect ("$server", “$user”, “$pass”) or die (‘I cannot connect to the database because: ’ . mysql\_error());[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]mysql\_select\_db ("$database");[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] $query = "INSERT INTO site (sitename) ".[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] "VALUES (’$sitename’)";[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] mysql\_query($query, $dbh) or die(‘Error, query failed’);[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]mysql\_close($dbh);[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] echo “Site - ‘$sitename’ - Has Been Added”;[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] }[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]?\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]Add A Site [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]\<form method=“POST”\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<table width=“700” border=“0” cellpadding=“2” cellspacing=“1” class=“box” align=“center”\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<tr\> [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<td width=“100”\>Site Name\</td\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<td\>\<input name=“sitename” type=“text” class=“box” id=“sitename”\>\</td\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \</tr\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<td width=“100”\>&nbsp;\</td\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<td\>&nbsp;\</td\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \</tr\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<tr\> [/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \<td colspan=“2” align=“center”\>\<input name=“save” type=“submit” class=“box” id=“save” value=“Save Site”\>\</td\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \</tr\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue] \</table\>[/COLOR][/SIZE]  
[SIZE=1][COLOR=RoyalBlue]\</form\>[/COLOR][/SIZE]  
[/INDENT]  
I get the Error, query failed,

I can’t seem to figure out what went wrong…

I am running…

PHP ver. 4.4.1  
Mysql ver. 4.1.13-standard-log

Cheers,

Jonahholliday
