Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/sites/miraclehosting.co.uk/public_html/scdc.php on line 169
---------------------------------------------------------------------------------------
Can anyone help here this is doin ma ed in!! gggrrrhhhhh
i get the above result when Load the script into the browser.
here is the form:
<form action="scdc.php" method="post" name="chooser">
<label>Select Parish </label>
<select name="chooser" id="chooser">
<option value="1">Abington Pigotts</option>
<option value="2">Arrington</option>
<option value="3">Barbraham</option>
<option value="4">Balsam</option>
<option value="5">Bar Hill</option>
<option value="6">Barrington</option>
<option value="7">Barton</option>
<option value="8">Bassingbourn-Cum-Kneesworth</option>
</select>
<input type="submit" name="select" value="select">
</form>
although there is 97 options i just havent given all of them for obvious reasons.
Here is the php:
<?php
// get variable after selecting something from the dropdown with name 'chooser'
$select = $_POST['select'];
// if something has been chosen
if (!empty($select)) {
// get the chosen value
$chooser = $_POST['chooser'];
// select the type from the database
// database connection details (change to whatever you need)
$HOST = 'localhost';
$DATABASE = '******';
$USER = '********';
$PASSWORD = '********';
// connect to database
if(!$conn=mysql_connect('localhost','web244-scdc','hartley07')) {
echo("<li>Can't connect to $HOST as $USER");
echo("<li>mysql Error: ".mysql_error());
die;
}
// select database
if (!mysql_select_db($DATABASE,$conn)) {
echo("<li>We were unable to select database $DATABASE");
die;
}
// if everything successful create query
// this selects all rows where the type is the one you chose in the dropdown
// * means that it will select all columns, ie name and type as i said above
$sql_query = "SELECT * FROM base_data WHERE type='$chooser'";
// get the data from the database
$result = mysql_query($sql_query,$conn);
// output data
while ($details = mysql_fetch_array($result, MYSQL_ASSOC)) {
// print out the name
echo('Parish: '.$details['ParishName'].' - ');
// print out the type
echo('Owner Occupier Household: '.$details['OwnerOccupierHousehold'].'<br>');
}
// close mysql connection
mysql_close($conn);
}
?>
The line highlighted in red is causing the problems. please help?