I having troubles with this code I'm getting a error code.
Please not this is not an assignment its from a book called PHP Bible. This book is loaded with errors.
Warning: mysql_fetch_arr ay() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/testing/10/ch21/date_prefs.php on line 33 (note line 33 is in bold text)
or
$pref_arr = mysql_fetch_arr ay($result); note I'm also get errors on other examples in this book.
If you need the db and table information please let me know.
Any help would be great.
nomad
Please not this is not an assignment its from a book called PHP Bible. This book is loaded with errors.
Warning: mysql_fetch_arr ay() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/testing/10/ch21/date_prefs.php on line 33 (note line 33 is in bold text)
or
$pref_arr = mysql_fetch_arr ay($result); note I'm also get errors on other examples in this book.
Code:
<?php
// Subscriber ID is stored in a cookie on the user's browser
$sub_id = $_COOKIE['userID'];
// Open connection to the database
mysql_connect("localhost", "nomad", "nomad") or die("Failure to communicate with database");
mysql_select_db("test");
// If the form has been submitted, record the preferences
if ($_POST['submit'] == 'Submit') {
$height = $_POST['height'];
$haircolor = $_POST['haircolor'];
$edu = $_POST['edu'];
// Update value
$query = "UPDATE qualities
SET height = $height, haircolor = $haircolor, edu = $edu
WHERE subscriber = $sub_id";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
$success_msg = '<P>Your preferences have been updated.</P>';
} else {
error_log(mysql_error());
$success_msg = '<P>Something went wrong.</P>';
}
}
// Get the values
$query = "SELECT height, haircolor, edu FROM qualities WHERE subscriber = $sub_id";
$result = mysql_query($query);
[B]$pref_arr = mysql_fetch_array($result);[/B]
$height = $pref_arr[0];
$haircolor = $pref_arr[1];
$edu = $pref_arr[2];
// Assemble the radio button part of the form
...more code below
?>
Any help would be great.
nomad
Comment