473,657 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql_fetch_arr ay() Warning

nomad
664 Recognized Expert Contributor
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.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // Subscriber ID is stored in a cookie on the user's browser
  4. $sub_id = $_COOKIE['userID'];
  5.  
  6. // Open connection to the database
  7. mysql_connect("localhost", "nomad", "nomad") or die("Failure to communicate with database");
  8. mysql_select_db("test");
  9.  
  10. // If the form has been submitted, record the preferences
  11. if ($_POST['submit'] == 'Submit') {
  12.   $height = $_POST['height'];
  13.   $haircolor = $_POST['haircolor'];
  14.   $edu = $_POST['edu'];
  15.  
  16.   // Update value
  17.   $query = "UPDATE qualities
  18.             SET height = $height, haircolor = $haircolor, edu = $edu
  19.             WHERE subscriber = $sub_id";
  20.   $result = mysql_query($query);
  21.   if (mysql_affected_rows() == 1) {
  22.     $success_msg = '<P>Your preferences have been updated.</P>';
  23.   } else {
  24.     error_log(mysql_error());
  25.     $success_msg = '<P>Something went wrong.</P>';
  26.   }
  27.  
  28. }
  29.  
  30. // Get the values
  31. $query = "SELECT height, haircolor, edu FROM qualities WHERE subscriber = $sub_id";
  32. $result = mysql_query($query);
  33. $pref_arr = mysql_fetch_array($result);   
  34. $height = $pref_arr[0];
  35. $haircolor = $pref_arr[1];
  36. $edu = $pref_arr[2];
  37.  
  38. // Assemble the radio button part of the form
  39. ...more code below
  40.  
  41. ?>
If you need the db and table information please let me know.

Any help would be great.

nomad
Dec 30 '09 #1
2 3688
code green
1,726 Recognized Expert Top Contributor
The error message means mysql_query() returned FALSE,
which means an error occurred.
Try the query on its own
Dec 30 '09 #2
Dormilich
8,658 Recognized Expert Moderator Expert
or try mysql_error().
Dec 30 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2852
by: Robert | last post by:
<?php echo "HI " . $name; $result = mysql_query("SELECT * FROM album WHERE username='{$name}'"); while ($next_row = mysql_fetch_array($result)) { $album_name = $next_row; echo "<a href=\"main.php?album=$album_name\"><font size=\"+1\" color=\"#FFFFFF\">
2
1791
by: wrw[three] | last post by:
Hey Okay so i have a page that lists a bunch of clients... then another page that would limit it to a specific chosen client.... the one that lists all the clients is working just fine, however when i limit the mysql query with "WHERE 1 AND last_name LIKE Harder" it gives me these errors Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...
3
3426
by: Pratchaya | last post by:
Hi Everyone ============================================================== About PHP::: Error/Problem PHP Warning: mysql_fetch_array(): ============================================================== In the past i use my code/script work fine with Mandrake 9.1 - 10.1 ( + apache ,mysql ) Now i move to redhat EL4 with the same code/script
9
7419
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " . mysql_error()); mysql_select_db("my_dbf") or die("Grr");
1
2086
by: myaashik | last post by:
Hello! All I have a Error message saying that: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/rocks/public_html/colorado3.php on line 32 I have error on this code below: <html> <head> <titleColorado</title>
1
2702
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 113 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on line 127 My code is below. Any help would be much appreciated. ...
11
3591
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this when there is no result "empty table" how can i do a quick fix to say No Results... row 88: if ($myrow = mysql_fetch_array($result)) { do { if ($rowcolor == 1) {
11
4738
by: chemlight | last post by:
I'm having a problem. I'm sure I'm going to kick myself over the answer... I have a table that stores vendors and their languages. This table starts out blank. I am querying the table to see if a vendor has been added to the table yet. The problem is, if they haven't been added, I can't seem to get the script to realize that. here is what I am trying to do. $testvend = SELECT language FROM vendor_details WHERE id = $vendorid ...
1
2152
by: byteit101 | last post by:
I was working with OOP, and was testing a sql result class, but it gives me the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. I think it has to do with assignment or garbage collection $con = MYSQLconn(); $res = DSQL::PSQL('SELECT * FROM cat_nav',$con); $res2 = DSQL::PSQL('SELECT * FROM cat_nav',$con); $superres = new SQLResult($res2, $con); while ($ar = Get($res)) { ...
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.