473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to fix this query error

123 100+
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\blog\blogpost.php on line 11
how can i fix thes error above this is my code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  class BlogPost  
  3.  {  
  4. public $id;  
  5.  public $title;  
  6.  public $post;  
  7.  public $author;
  8.  if (!empty($inAuthorId))  
  9.      {  
  10.          $result = mysql_query("SELECT first_name, last_name FROM people WHERE id = " . $inAuthorId);  
  11.          $row = mysql_fetch_assoc($result);  
  12.         $this->author = $row["first_name"] . " " . $row["last_name"];  
  13.      }
  14. ?>
  15.  
Aug 18 '10 #1
1 1088
JKing
1,206 Expert 1GB
There could be several reasons for this.

Have you connected to the mysql server and selected your database?

Are you using the right field and table names?

Modify your code as follows to get some more information on why the query is failing.
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.  class BlogPost  
  4.  {  
  5. public $id;  
  6.  public $title;  
  7.  public $post;  
  8.  public $author;
  9.  if (!empty($inAuthorId))  
  10.      {  
  11.          $result = mysql_query("SELECT first_name, last_name FROM people WHERE id = " . $inAuthorId) or die(mysql_error());  
  12.          $row = mysql_fetch_assoc($result);  
  13.         $this->author = $row["first_name"] . " " . $row["last_name"];  
  14.      }
  15. ?>
  16.  
Aug 18 '10 #2

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

Similar topics

1
by: Stijn Goris | last post by:
I get an error when trying to insert a new row: query error- 5 - Duplicate entry '80.200.213.102 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Avant Browser ; MyIE2; .NET CLR 1.0.' for key 1...
2
by: Jim Hatfield | last post by:
I'm using: "select min(objid) from table_name where objid > $objid" to select the next row in a sequence where there may be gaps. It works fine unless the where clause results in an empty set. ...
1
by: Dalan | last post by:
I can't seem to find a workaround of Query Syntax Error. Actually, the query performs just fine, except when the last record on a related subform is deleted, then it generates a Runtime Error 3075...
2
by: Jean | last post by:
Hello everyone, I was having the following problem with a query, and after failing to find a similar solution on these newsgroups I decided to post here. I am quite new to Access, so would...
3
by: jallegue | last post by:
I am working with MS-Access 2002. The two tables that I am working with are: dbo_IDX_FRS_account_bal_by_month ==> this is a linked table to SQL == local table The query that is executed is...
14
by: Tom | last post by:
Using AccessXP in 2000 mode. I have the following tables --- TblLocation LocationID PropertyID StateID CountyID CityID
5
by: Annie | last post by:
hello guys, I have little experience working with C# and MS Access ... I am having an insert query with one datetime field and a boolean and couple of text and number fields as below: ...
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
8
Cintury
by: Cintury | last post by:
The problem is I have a function that I've created and stored in a module. I call it as an expression (e.g. total: Function(parameter)). I'm receiving the error 3061: too few parameters, expected 1....
12
by: lupis | last post by:
I am creating a query to find unmatched rows between a local access table and an online MS SQL Server table based on the PK field ID. This is working without any flaws. My problems start when I run a...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.