• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Cannot Retrieve Data from Database: PHP

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All.

I need some help with retrieving some data from my PHP server. I expect some data to be shown, but I see none. I followed a couple Youtube tutorials - they all said the same thing. When I tried it it, I did not get the desired result.

Here is the code that I used:



Here is the text of the PHP My Admin screen(to show that I have some data):

Full texts
ID
PRODUCT_NAME
PRODUCT_NOTES
SHOP_URL
SHOP_NAME
PRODUCT_LOCATION

2
Hi
Hi
HI
HI
Hi

.

This is what I get when I run it, and $_POST['product']= Hi.


Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\product\getdata.php on line 41
Product Name Product Notes Shop URL Shop Name Product Location


All help would be greatly appreciated.

 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try displaying your sql. The parameter may not be what you expect causing the sql to not return a resource for the mysql_fetch_array function.

Remember to put quotes in sql.
 
Vicky Moore
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. I just would like to know which SQL you are talking about.
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vicky Moore wrote:Thank you. I just would like to know which SQL you are talking about.



Line 23 of your original posting.

Say your variable $requested_product = "ABC"

When you display that is it showing :
SELECT * FROM products WHERE PRODUCT_NAME =  ABC ;
or
SELECT * FROM products WHERE PRODUCT_NAME = 'ABC' ; <- with quote
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic