473,402 Members | 2,055 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,402 software developers and data experts.

Problem with Login/Registration System

This is my first post onto the forum. So first off, I'd like to say hello to everyone.

I just started working on a login/registration system and I am trying to have a feature where the user will login and they can see all of their information about their account (e-mail, website, state, etc.). Unfortunately I have something wrong with the code and I keep receiving the following error message.

"Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/home/cyphrs07/public_html/database/memberspage.php on line 38"

Obviously something is wrong with the SQL query. I've tried messing around with all sorts of different variables and structures for the query but to no avail. Here is the code below.

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. // Database connection
  3. $dbhost = "localhost";
  4. $dbname = "********";
  5. $dbuser = "*******";
  6. $dbpass = "*********";
  7.  
  8. mysql_connect($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
  9. mysql_select_db($dbname) or die(mysql_error());
  10.  
  11. // Check for cookie, if cookie exists, set variable
  12. if(!empty($_COOKIE['electionday'])) {
  13.  
  14. #######PROBLEM############
  15. // Grab information about user
  16. $check = mysql_query("SELECT * FROM users WHERE userid = '$electionday'")or die(mysql_error());
  17. $result = mysql_query($check);
  18. $num = mysql_num_rows($result); 
  19. ######PROBLEM#############
  20.  
  21. // Loop for grabbing results
  22. $i=0;
  23. while ($i < $num) {
  24. $userid=mysql_result($result,$i,"userid");
  25. $datejoined=mysql_result($result,$i,"datejoined");
  26. $name=mysql_result($result,$i,"name");
  27. $country=mysql_result($result,$i,"country");
  28. $state=mysql_result($result,$i,"state");
  29. $zip=mysql_result($result,$i,"zip");
  30. $im=mysql_result($result,$i,"im");
  31. $website=mysql_result($result,$i,"website");
  32. $politics=mysql_result($result,$i,"politics");
  33. $privemail=mysql_result($result,$i,"privemail");
  34. $pubemail=mysql_result($result,$i,"pubemail");
  35. $dob=mysql_result($result,$i,"dob");
  36. $college=mysql_result($result,$i,"college");
  37. $occupation=mysql_result($result,$i,"occupation");
  38. $gender=mysql_result($result,$i,"gender");
  39. $marital=mysql_result($result,$i,"marital");
  40. ?>
  41. <p>User Name: <?php echo "$userid"; ?></p>
  42. <p>Member Since: <?php echo "$datejoined"; ?></p>
  43. <p>Real Name: <?php echo "$name"; ?></p>
  44. <p>Country: <?php echo "$country"; ?></p>
  45. <p>State: <?php echo "$state"; ?></p>
  46. <p>Zip Code: <?php echo "$zip"; ?></p>
  47. <p>Instant Messaging: <?php echo "$im"; ?></p>
  48. <p>Website: <?php echo "$website"; ?></p>
  49. <p>Politics: <?php echo "$politics"; ?></p>
  50. <p>E-Mail for Password: <?php echo "$privemail"; ?></p>
  51. <p>Public E-Mail: <?php echo "$pubemail"; ?></p>
  52. <p>Date of Birth: <?php echo "$dob"; ?></p>
  53. <p>College: <?php echo "$college"; ?></p>
  54. <p>Occupation: <?php echo "$occupation"; ?></p>
  55. <p>Gender: <?php echo "$gender"; ?></p>
  56. <p>Status: <?php echo "$marital"; ?></p>
  57. <?php
  58. ++$i;
  59. }
  60. mysql_close();
  61.  
  62. // Display error message
  63. } else {
  64. echo "You are not logged in, please log in below.<br><br>";
  65. include 'login.php';
  66. }
  67. ?>
  68.  
If anyone can help me it would be much appreciated, I'm trying to get this done within the next few days. Thank you.
Aug 14 '07 #1
2 1817
pbmods
5,821 Expert 4TB
Heya, sheaguevara. Welcome to TSDN!

The only valid MySQL resource identifier in your code is $check, not $result. You only need to call mysql_query() once per query.

You may also find mysql_fetch_assoc() to be a more efficient way to fetch your result set.
Aug 14 '07 #2
Thanks for the advice! Everything seems to be working now!
Aug 19 '07 #3

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

Similar topics

3
by: sacred_warrior | last post by:
After I saw Scott Guthrie's ASP.NET 2.0 with VS2005 seminar (which I think was great because I got to see all the cool features of VS 2005), I created a website using VS 2005 with option of File...
2
by: drah | last post by:
Hello not exactly sure if it is a php script problem or a database/table issue i apologize if i'mposting in wrong category. I was asked to put a login script on a site for someone and i made the...
9
by: Ben | last post by:
Hello, I'll bet this has been asked a million times but I can't seem to find a thread that gives the clear example I need. This PC has MySQL and IIS configured and running. The MySQL database is...
2
by: nvidia1 | last post by:
Hi this is my first post but so far this is pretty good site. I have a file called index.html with the following code: <!-- index.html --> <html> <head><title>Student Registration...
0
by: sandy | last post by:
hello,,,,,,,,, i am creating login page using Perl/CGI facing prob... able to connect DB but from there facing prob If u have related code of login page in Perl please send me on...
1
by: Tarcetial | last post by:
Im trying to make a personal website with a log in/registration system. I found some help with the log in and now i just need some help with the registration. This is the coding im already using: ...
2
by: sweatha | last post by:
Hi friends This is sweatha, fresher MCA 2007 batch. Right now I am working in asp.net platform. My dillema is that I have created a registration form with the fields as username & password. And if...
1
by: geetamadhavi | last post by:
Hi All, I have developed a php applciaiton where a new window is opening on checking the whether valid user orntot how to make that in same window after checking i have die(' not valid user ' ); i...
10
by: DavidPr | last post by:
I'm having a problem putting entries into a table. I have a job board and I want to prevent certain companies from being able to register - again. I don't allow certain type ads, so when they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.