944,052 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 3785
  • MySQL RSS
Jun 30th, 2005
0

Single cell query!

Expand Post »
How can i display result of a single cell query?
my query is
$author=$_POST["authorname"];
$q="Select authorid from authors where AuthorName=$author";
$resultauthor=mysql_query($q,$connect);
$num=mysql_num_fields($resultauthor); <<Error coming here! :( mysql_num_fields(): supplied argument is not a valid MySQL result resource in
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bennetjosem is offline Offline
9 posts
since Sep 2004
Jun 30th, 2005
0

Re: Single cell query!

The error is here
MySQL Syntax (Toggle Plain Text)
  1. mysql_query($q,$connect);

Try chaging the query to this
MySQL Syntax (Toggle Plain Text)
  1. $q="Select authorid from authors where AuthorName='$author'";
Probably its because of the missing '' or simply, you´re not getting the POST variable authorname

Try this
MySQL Syntax (Toggle Plain Text)
  1. $author=$_POST["authorname"];
  2. echo $author;

Do you get what you expect?
If nothing of this works, then you have a problem in $connect

Cheers
Reputation Points: 10
Solved Threads: 1
Light Poster
darklordsatan is offline Offline
26 posts
since Jun 2005
Jul 1st, 2005
0

Re: Single cell query!

thnx. I just figured it out! thnx again
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bennetjosem is offline Offline
9 posts
since Sep 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Find table size
Next Thread in MySQL Forum Timeline: Copy tables from one MySql DB to another MySql DB





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC