PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 1st, 2000, 08:42 AM
quickdesign
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I got this error message:
"Warning: 0 is not a MySQL result index"

I use the following code:

$connection = mysql_connect("localhost", "username", "password");
mysql_select_db("qdesign", $connection);


$query = "SELECT * FROM guestbook WHERE id=$display ";
$result = mysql_query($query, $connection);


while($row = mysql_fetch_array($result)) {

print("<b>n");
print($row["subject"] . "<br>n");
print("</b>n");
print($row["name"] . "<br>n");
print($row["email"] . "<br>n");
print($row["url"] . "<br><br>n");
print("<table border=0><tr><td width=300>nn");
print($row["msg"] . "<br><br><br>n");
print("</td></tr></table>nn");
print("<a href="guestbook.php3?what=view">Go back to the guestbook</a>");

}


what's wrong...

When I enter the page I have a query with me.
Like this

www.server.com/page.php3?display=1

I want to view the same id in the database
as in the display variable.

Thanks.

Reply With Quote
  #2  
Old January 1st, 2000, 01:29 PM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
After your query add the following line:

print mysql_error();

to see what's wrong. The 0 result index means that mysql returned an error.

It's not readily apparent from your code what the error might be.

Reply With Quote
  #3  
Old January 1st, 2000, 02:17 PM
moderator
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
test . . .please ignore

Reply With Quote
  #4  
Old January 3rd, 2000, 02:29 PM
aweigert aweigert is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Rochester, NY, United States
Posts: 9 aweigert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to aweigert
you query is flawed

$query = "SELECT * FROM myTable WHERE myField = 'ThisItem'";
ThisItem must be enclosed in quotes...

- Regards

Reply With Quote
  #5  
Old January 3rd, 2000, 02:54 PM
cbolt cbolt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Posts: 2 cbolt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The query is not flawed if id is a column which uses a numeric data type (*int, which is probably what it is). Only strings must be enclosed in quotes.

Reply With Quote
  #6  
Old February 2nd, 2000, 05:41 PM
brett_webb brett_webb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: NY, NY,USA
Posts: 18 brett_webb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm having trouble with these lines:
$dept_name = mysql_query ("SELECT department_name FROM dept_info WHERE dept_id = '$row["dept_id"]'");
print $dept_name;

It seems to be printing the array index, and not a result from the mysql_query. The Query works if I type it in the command line with an explicit value substituted for the $row["dept_id"]

This line :
print $row["dept_id"];
is printing the correct value to HTML.

Here's the code:

$result = mysql_query ("SELECT * FROM jobs");

print ("<table>");
if ($row = mysql_fetch_array($result)) {
do {
print ("<tr><td bgcolor=#cccccc>");
print $row["position_name"];
print ("</td><td>");
print ("<b>");
print $row["dept_id"];
print ("</b>");
$dept_name = mysql_query ("SELECT department_name FROM dept_info WHERE dept_id = '$row["dept_id"]'");
print $dept_name;
print ("</td></tr>"); }
while($row = mysql_fetch_array($result)); }
else {print "Sorry, no records were found!";}

print ("</table>");



[This message has been edited by brett_webb (edited February 02, 2000).]

Reply With Quote
  #7  
Old February 3rd, 2000, 05:09 AM
PAV PAV is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 1999
Location: Netherlands
Posts: 77 PAV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Hi,

There are 'conflicting' double-quotes in the string, you can try:

$selectquery = "SELECT department_name FROM dept_info WHERE dept_id = " . $row["dept_id"];
$dept_name = mysql_query($selectquery);

Peter

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > MySQL and PHP... errors..

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap