# Deleting MySQL records from PHP

**URL:** https://forum.kirupa.com/t/deleting-mysql-records-from-php/136125
**Category:** Uncategorized
**Created:** [February 2, 2005, 3:08pm UTC](https://forum.kirupa.com/t/deleting-mysql-records-from-php/136125 "2005-02-02T15:08:10Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![A\_I\_R\_H\_E\_A\_D](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@A\_I\_R\_H\_E\_A\_D](https://forum.kirupa.com/u/A_I_R_H_E_A_D)
#### Post date: [February 2, 2005, 3:08pm UTC](https://forum.kirupa.com/t/deleting-mysql-records-from-php/136125/1 "2005-02-02T15:08:10Z")

</div>

Hello peeps,

I am proud of myself. With the help of this forum, Codewalkers and a few good books I have managed to get a web page to add records to a web based database. No mean feat when you consider a few short weeks ago I thought Perl and PHP were the same thing…

I want to select and delete records of the database now but I always get an error akin to this:

**Parse error** : parse error in **/home/.sites/3/site227/web/data/TUK/delete.php** on line **3**

I don’t have the first clue what is going wrong, here is my code:  
\<?php  
if (isset($\_POST[‘submit’])){  
$db = mysql\_connect(“localhost”, “user”, “password”) OR die mysql\_error();  
mysql\_select\_db(“database”,$db) OR die mysql\_error();  
function escape\_data ($data){  
global $db;  
if (ini\_get(‘magic\_quotes\_gpc’)){  
$data = stripslashes ($data);  
}  
return mysql\_real\_escape\_string($data, $db);  
}  
$message = NULL;

if (empty($\_POST[‘selectedrecord’])){  
$u = FALSE;  
$message = ‘\<P\>Enter company\</P\>’;  
} else {  
$u = escape\_data($\_POST[‘selectedrecord’]);  
}  
if ($u){  
$query = “SELECT record\_id FROM tuk\_members WHERE (company\_name=’$u’)”;  
$result = @mysql\_query ($query);  
$num = mysql\_num\_rows ($result);  
if ($num == 1){  
$row = mysql\_fetch\_array($result, MYSQL\_NUM);  
$query = “DELETE FROM tuk\_members WHERE record\_id=$row[0]”;  
$result = @mysql\_query ($query);  
}  
}  
?\>  
\<form action ="\<?php echo $\_SERVER[‘PHP\_SELF’]; ?\>" method=“post”\>  
\<P\>Enter Company:\<input type=“text” name=“selectedrecord” value="\<?php if (isset($\_POST[‘selectedrecord’])) echo $\_POST[‘selectedrecord’]; ?\>" /\>\</P\>  
\<input type=“submit” name=“submit” value=“submit”/\>

Can anyone help??

AH
