Jul 9, 2008

Script Not Working :s - mysql errors

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Script Not Working :s - mysql errors

AlternativeNick
CODE
process_login.php: Process the login.

<?
$host = "localhost";// the host that u are connecting
$username = "root";// user name
$password = ""; // passworld
$basedatos = "forum"; //Dont change this1.
$db = mysql_connect($host, $username, $password);
mysql_select_db($basedatos, $db);
$user= $_REQUEST['username'];
$pass= md5($_REQUEST['password']);
$query1= "SELECT * FROM smf_members WHERE memberName='$user'";
$mkquery= mysql_query($query1,$db);
$row1= mysql_fetch_assoc($mkquery);
if ($row1['memberName'] == $user) {
if ($row1['passwd'] == $pass) {
/* I seted them to 1 hour duration of login. If you want you can change it. */
setcookie("altuser",$user,time()+3600);
setcookie("altpass",$pass,time()+3600);
?>
<script language="javascript">
alert("Login correct, redirecting to main page.")
location.href= "URL OF MAIN PAGE";
</script>
<?
}
else {
echo "The password is incorrect.";
}
}
else {
echo "The user doesnt exist.";
}

compare_us.php: This page MUST be included in the pages that u want to check access...

<?
$host = "localhost";// the host that u are connecting
$username = "root";// user name
$password = ""; // passworld
$basedatos = "forum"; //Dont change this1.
$db = mysql_connect($host, $username, $password);
require_once("dbconnect.php");
mysql_select_db($basedatos, $db);
if(isset($HTTP_COOKIE_VARS['altuser']) && isset($HTTP_COOKIE_VARS['altpass'])) {
$user= $HTTP_COOKIE_VARS['altuser'];
$pass= $HTTP_COOKIE_VARS['altpass'];
$query1= "SELECT * FROM smf_members WHERE memberName='$user'";
$mkquery= mysql_query($query1,$db);
$row1= mysql_fetch_assoc($mkquery);
if ($row1['memberName'] == $user) {
if ($row1['passwd'] == $pass){
$loginok= true;
}
else {
$loginok= false;
echo "The password is bad. Login again please.";
}
}
else {
$loginok= false;
echo "Something is wrong... The user doesnt exist?...";
}
}
?>

Finally... This finishes... To see if the user is loged in you only need to do:
<?
require_once("compare_us.php");
if ($loginok == true) {
?>
HTML HERE
<?
}
else {
echo "You must login to do that...";
}
?>


Thats the code up there ^^ a friend wrote it for me, and weve tried multiple ways of accomplishing this, but it just doesnt work.

This is the error im getting :
QUOTE
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/altscr/public_html/scriptdev/process_login.php on line 12

 

 

 


Reply

beeseven
The only thing I can think of would be that you might not be getting any rows. You could use mysql_num_rows or run that SQL statement directly to check.

Reply

shadowx
Yes it could be that there are no rows but at the php manual it ays it will just return a false value if there are no more rows. i assume this is true if there are no rows atall also.

I would do some error checking to make sure that the query is going through perfectly, i see no reason why not but its good just to make sure that the error is definately coming from the right place
Just add

CODE
or die (mysql_error(););


after performing the query and selecting the DB just to make sure that valid parameters are being used by fetch_assoc. Another way to do this would be using the mysql_fetch_array(); function. They both do the same thing but ive never had problems with fetch_array so i personally find it easier to use, but you might not, its just an idea.

If there are no other errors in the code then im not sure what to say but you can always search the php manual online (just google the function youre after and youll get the website within the first 3 or 4 results normally). And good luck! Its tedious when things like this happen!

 

 

 


Reply

Horranus
If you are using a MySQL version less than 5, this is the problem:
$query1= "SELECT * FROM smf_members WHERE memberName='$user'";

In MySQL < 5 you need to enclose the table name in ` like this:
$query1= "SELECT * FROM `smf_members` WHERE memberName='$user'";

If that isn't the problem you could just try to bypass the mysql_fetch_assoc comparison by using a number comparison instead I.E.:

CODE

...

$userexist = @mysql_num_rows($query)
if ($userexist == 1)
{
$query = @mysql_query("SELECT passwd FROM `smf_members` WHERE memberName='$user'")or die('Could not complete query: ' . mysql_error());
$passcheck = @mysql_num_rows($query)
if ($passcheck > 0)
{

...

Reply

Spectre
QUOTE(Horranus @ Sep 13 2006, 01:53 AM) *

If you are using a MySQL version less than 5, this is the problem:
$query1= "SELECT * FROM smf_members WHERE memberName='$user'";

In MySQL < 5 you need to enclose the table name in ` like this:
$query1= "SELECT * FROM `smf_members` WHERE memberName='$user'";


You don't need to do that in any version of MySQL - although you can, and it may be considered more 'correct' by some, there is absolutely no requirement to enclose table names in `.

The error just means that the query returned no values, as has been suggested. Simply add an conditional check, and it should work fine, such as:

CODE
if( $mkquery && @mysql_num_rows($mkquery) > 0 )


Also, you are not sanitizing the user input at all, allowing for the possibility of injection - eg. putting ' OR 1=1 in the username field.

Reply

QuickSilva
Kind of an old topic, but if anyone else has this error, i'll explain what it means. It basicly means it cannot find the table. So login to phpmyadmin and actualy check if the table is there. And if the table isn't there you will need to create it, but that is a whole different story so I won't go into it. If it does exist, well I don't know in that situation. wink.gif

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. cache:df_c62wei_wj:www.trap17.com/index.php/fopen-errors_t57225.html "process_login.php?$" - 443.74 hr back.
  2. smf_members passwd - 622.58 hr back.
Similar Topics

Keywords : script, working, s, mysql, errors

  1. Phpizabi Social Network Script
    (0)
  2. How To Make A View New Post Script?
    (5)
    Ok so i'm still working on the forum software i posted about a while back, but I have no idea
    how to do this. I want to make a view new post script, as this is one of the main things that my
    forum software dose not have that all other forums have. so does any body have an idea on how i
    would do this? Thanks.....
  3. Flash Wmode(transparent) Pramater In Firefox3(on Linux) - Not Working
    issue with flash transparancy and firefox3( on linux op. sistem) (0)
    Can anybody help me... Unfortunately I have an issue with firefox2-3 (under linux (ubuntu)
    operating sistem) and flash transparacy... The site structure is: Menu (dropdown with javascript)
    and under that a big flash with wmode=transparent param enabled.. On mouse-over the menu is not
    appearing because the flash hides it... With all other browsers it works. I understood that this
    is a flash plugin bug under linux - firefox2-3 Does anyone has a solution?....
  4. Adjusting Rows/cols Of Frames In Frameset Using Javascript Is Not Working In Firefox 3 Is Not Working
    (4)
    I am not able to adjust frames length/width in a frameset using java script functions I am using
    firefox 3. In below code changerows is not working for me. Where as same is working in IE6.
    Please help me in resolving this issue. Note: here frameset1 is the name given to the FRAMESET.
    CODE function changeRows() { parent.frameset1.rows="30%,70%" }function
    restoreRows() { parent.frameset1.rows="50%,50%" } ....
  5. Xobni - Working With Mails Got Easier.
    (0)
    This is for people using MS Office Outlook as their email client in office and home. How i wish
    outlook has so many features every time i start using it... But now that new things are being
    developed by third party vendors... Make things easier. One of the most important things that i
    kept looking for is an efficient search that is filled with index, etc. Sometimes its not very easy
    to search mails and files received via mails. Makes life a bit tough when i have to look for the
    files sent by others via mail. i am still in outlook 2003 and yet to upgrade and guess wh....
  6. Backup Not Working [resolved]
    (5)
    I am trying to backup my files on my account(in preparation for the next server disaster), and I am
    unable to download it. In my CPanel I goto the back-up screen to generate a full backup. Once
    that's done and its ready to be downloaded, It only downloads to 13% or 50mb before stopping.
    With and without a download manager. It doesn't help that resume is not supported in download
    managers. I have too many files on my account to backup with an FTP client, that would take hours
    and hours. What can I do to get a backup of my account?....
  7. Help With Xp - Autoupdate Not Working [resolved]
    Cannot enable autoupdate (13)
    Hi, I have this Sony system with XP SP2 installed and It got infected with a virus. It came as an
    attachment and I thought its a legit file since NOD32 found it clean. It was suspicious bcoz of its
    size ( /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> So
    NEways, I managed to clean up the system (0% traces of any suspicious activities so far) but since
    then my Auto-Update is turned off. If it were to be a pirated copy, I wouldn't have cared much
    but this is LEGIT /biggrin.gif" style="vertical-align:middle" emoid=":D" border....
  8. How Do I Find My Mysql Password? [resolved]
    Cannot access my MySQL (5)
    After all the recent problems, my account has been restored. I have setup my parked domain agin, and
    that works fine. However, I can no longer access my MySQL databases (I can from PHPMyAdmin, but
    that's all). I had to create a new user for my databases, and created the user with exactly the
    same username and password I had before, but some of my web pages do not let me access the pages I
    have associated with my databases. Where could i find out what my DB password is? (Although I am as
    good as sure I am using the right one). I have tried my old password, the new c....
  9. Please Explain Me Mysql
    How do i insert information into this config: (4)
    Hi, I wanted to try just to test how can i connect my website to another mysql server, but i have no
    idea how to insert the other mysql information such as port and host etc.... so here is the config
    file please give me an example CODE <?php // mySQL information $server =
    'FRESHSQL.COM:3306';                   // MySql server $username =
    'vasilevich';                      // MySql Username $password =
    '*******';                         // MySql Password $database =
    'vasilevich';                  // MySql Da....
  10. Remote Access Mysql
    (8)
    Is it possible to directly access my local database from my website? For example, if somebody
    submits info on my website, the info they submitted would be transferred to my local database
    directly. Is that possible? And if so, how do I set that up? The reason I don't want to upload
    my database to my subdomain is because it would be difficult to keep the website database and my
    local database in sync . . . or is there a way to do that? Thanks for any replies.....
  11. Guessing Php Script
    (0)
    I am looking for: freeware php quess the person in the photo game script....
  12. Help For My Seagate Sata Hard Drive!
    hard drive stops working randomly, please help! (7)
    I just bought that disk (seagate SATA 500G) half year ago and found it stop working randomly,
    resulting the whole system to be dead. BTW, I am using Win XP. I tried to use seatool, provied by
    seagate, to scan and repair the error, the program stop at the half of the process. I even can't
    format entirely, just do quick format. I don't know what I can do and have been pissed off for a
    few days. hope some people have this kind of experience and give me any idea. I don't want to
    loss my 500G data storeage. thanks in advance.....
  13. Webmail Server Script
    (2)
    Hi Guys! A friend of mine came to me asking me to help him write code for his server so that
    his clients can go on his site and create a webmail account. I told him I'm not a programmer but
    I googled the subject. I ran into SquirrelMail and was impressed with what it could do. Going
    through the documentation I saw this QUOTE There are only two requirements for SquirrelMail:
    A web server with PHP installed. PHP needs to be at least 4.1.0. Access to an IMAP server which
    supports IMAP 4 rev 1. I have php5 running on my XPproSP3 but I don't know....
  14. Ftp Access Has Stopped Working All Of A Sudden [resolved]
    read (5)
    heres the login information i use add : ftp.sub-domain.qupis.com user: my username pass: my pass
    port: 21 i already opened a ticket and it seem pending at the moment but does anybody know a
    solution... im already having problems with php files. im getting a password error but i can open
    my account via web easily....
  15. Html Form!
    Using MySQL?! (4)
    Hey, I need your help again! I need some good working tutorial how I can update my SQL through
    HTML form. I did use some tutorials online found with the help of google; but they do not work
    properly; I mean there are still small mistakes. I need to have a good tutorial to follow. It
    should be based on security and more things. It has to be done in proper way.......
  16. Mysql-essential-5.0.51 Installion Problem
    please help me.(urgent) (2)
    Dear friend, please help me. Iam working on php project (matchmaking site). I have downloaded mysql
    essensial 5.0.51. When i was installing mysql 5.0.51, i got following error - Error 1901: Error
    attempting to read from the source installation database:
    c:\windows\installer\527ec6.msi What is solution of this problem ? Iam using
    windows xp professional version 2002 (service pack 2). Please post your reply. Iam waiting for your
    answer. ....
  17. Need Help Installing Dolphin Community Script!
    (5)
    I'm not sure if this is the right place to post this but I really need help in installing the
    dolphin community script. I have absolutely no previous experience of scripts or programming. I
    would really appreciate if someone could walk me through it step-by-step, or even do it for me by
    logging into my cpanel. I have tried to install it my self but I'm a little confused. I'm
    sure it won't take very long at all for someone who has done this before.....
  18. Database With Mysql++
    getting mySQL++ to work with trap17 (7)
    Hi, I'm trying to build an online game and figured the easiest way to do the server list would
    be to make a mySQL database for it; however, I use the con() command on the IP i get from pinging my
    website and I always get an abnormal program termination; however, it will work with the mySQL on my
    own machine. The code is below: CODE #include <iostream> #include <iomanip>
    #include <mysql++> #include "pass.h"//holds my password (i program at
    school) int main(void) {     Connection con("t3jem3_test","....
  19. Mysql Won't Update
    (4)
    Ok, so I'm making some arcade administration software so I don't have to add games the hard
    way, well anyway, one of the features I have is that on the homepage is a featured author and as
    such I just have it so it updates one line in the mySQL. Well, the page with the form passes on the
    varibles fine and the updating page recieves them because I echoed everything, then I build the
    query and I even echo the query and it comes out exactly how I want it to, but for some reason, the
    database itself won't update even though all the varibles are there. Here's....
  20. Invite Script..
    (2)
    I didn't know where else to put it /sad.gif" style="vertical-align:middle" emoid=":("
    border="0" alt="sad.gif" /> If moderators find another forum more suitable plz move this one
    /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> I am looking
    for some sort of sript or program that let's people on your website invite friends. Like they
    put in their Emailadress and mails are send to everyone in their list.. I hope someone can help me
    /sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Greetzz....
  21. Html Code Tester. Online Script
    (15)
    Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
    this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
    Current script: CODE <?php //Save this as something like htmltest.php function
    CheckForm() { $html_unsafe=$_POST['code']; //Gives us our user
    input $html_safe=str_replace("<?php"," ",$html_unsafe);
    //Starts security measures $html_safe=str_replace("?>","
    ",$html_sa....
  22. Is It Possible To Access The Mysql Remotely?
    (10)
    I like to experiment with a lot of things and I was thinking of making a sort of instant messenger
    in Python, but I want to let people have actual accounts so I need to be able to access the mySQL
    remotely. If that's not possible, are we allowed to run Python scripts on the server?....
  23. Check Referrer To Prevent Linking Yours From Other Sites
    Check referrer with Php and Mysql (8)
    Check Referrer Using Php To Prevent People Linking To Your Downloads From Other Sites Ever
    find that found some people are listing items, images and tuts and linking directly to the download
    url (those that are like my photoshop tutorial.php?id=0), which is a .php to count the number of
    downloads. To prevent this, you can add a piece of code to the download pages that checks which page
    referred them to the download page: if it's my domain, it downloads the file normally, if
    it's not, it will redirect to my home page instead. Important : Not all browser....
  24. Mysql Database Size
    related to the free database space (6)
    hi all! this is my first post /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> and i have a doubt, how much mysql space i am allowed to use... i mean how
    much is available for my free account....
  25. Import From Excel File Into Mysql Database
    (7)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  26. Test Your Php Pages W/o Upload/internet
    complete *working* guide on how to test your php pages (57)
    In this tutorial, I'm going to show you how to test your PHP pages without the Internet or
    uploading the files to your trap17 server. This tutorial is similar to doom's, but the links he
    provided does not work, so I decided to make my own tutorial with working links. The program that I
    will be using for this tutorial is called XAMPP . XAMPP is a modification of the popular Apache
    server, and I'm using XAMPP because of its simplicity to install as well as maintain. The
    current version of XAMPP is 1.4.13 and it has the following bundled in the download: QUOT....
  27. Free Weather Feed Script
    (1)
    If you are tired of providing your clients with weather feeds that take visitors off of their site
    or slam their site with ads, I finally found one after searching for hours. Here's a link to a
    FREE php script that pulls the feed directly from any airport in the world to your site. It is easy
    to customize and has simple, well documented installation instructions.
    http://www.mattsscripts.co.uk/mweather.htm hope you find it helpful... a good one for designers
    to archive as you will most likely need it some day for a client. Check out Matt's other free
    scripts....
  28. Php Quiz Script
    Make quizzes for your site. (20)
    Hello all, A little bit back I decided to make a quiz scriptjust out of no where lol. However it
    doesnt do anything special but I am going to make an email mod for it so that it will email results
    to your email address. So here is the basis of it. INSTRUCTIONS: Open a new page in your text
    editor and paste in the following code. CODE <?php $qid = "Quiz ID-00"; ?>
    <html> <head> <title><? echo "Gamers Pub $qid";
    ?></title> </head> <body> <p><h3><? echo "....
  29. Complete Login System
    With PHP + MYSQL (55)
    Its an complete login sistem made and tested by me and I think itwill be very usefull for people who
    are tryn to learn PHP. First, let's make register.php: CODE <?
    include("conn.php"); // create a file with all the database connections
    if($do_register){ // if the submit button were clicked if((!$name)
    || (!$email) || (!$age) || (!$login) ||
    (!$password) || (!$password2)){ print "You can't let
    any fields in blank....
  30. Sata Hard Drive Not Recognized By Windows
    WD 250gb SATA hard drive not working (11)
    Hi there! I recently re-installed windows on my 250 gb WD SATA hard drive. I had a 50 gb
    windows partition and the rest for files. First thing that happened was my system partition
    wouldn't boot and eventually chkdsk said that the mbr was unrecoverable. A friend recommended
    that i use a seperate parallel hard drive to load windows and then convert the disk to dynamic in
    disk management. I did this, but the computer crashed and now windows won't even load with the
    SATA hard drive connected. The BIOS sees the SATA hdd, but that's as far as I can get. I tri....

    1. Looking for script, working, s, mysql, errors

Searching Video's for script, working, s, mysql, errors
Similar
Phpizabi
Social
Network
Script
How To Make
A View New
Post Script?
Flash
Wmode(transp
arent)
Pramater In
Firefox3(on
Linux) - Not
Working -
issue with
flash
transparancy
and
firefox3( on
linux op.
sistem)
Adjusting
Rows/cols Of
Frames In
Frameset
Using
Javascript
Is Not
Working In
Firefox 3 Is
Not Working
Xobni -
Working With
Mails Got
Easier.
Backup Not
Working
[resolved]
Help With Xp
- Autoupdate
Not Working
[resolved] -
Cannot
enable
autoupdate
How Do I
Find My
Mysql
Password?
[resolved] -
Cannot
access my
MySQL
Please
Explain Me
Mysql - How
do i insert
information
into this
config:
Remote
Access Mysql
Guessing Php
Script
Help For My
Seagate Sata
Hard
Drive! -
hard drive
stops
working
randomly,
please
help!
Webmail
Server
Script
Ftp Access
Has Stopped
Working All
Of A Sudden
[resolved] -
read
Html
Form! -
Using
MySQL?!
Mysql-essent
ial-5.0.51
Installion
Problem -
please help
me.(urgent)
Need Help
Installing
Dolphin
Community
Script!
Database
With Mysql++
- getting
mySQL++ to
work with
trap17
Mysql
Won't
Update
Invite
Script..
Html Code
Tester.
Online
Script
Is It
Possible To
Access The
Mysql
Remotely?
Check
Referrer To
Prevent
Linking
Yours From
Other Sites
- Check
referrer
with Php and
Mysql
Mysql
Database
Size -
related to
the free
database
space
Import From
Excel File
Into Mysql
Database
Test Your
Php Pages
W/o
Upload/inter
net -
complete
*working*
guide on how
to test your
php pages
Free Weather
Feed Script
Php Quiz
Script -
Make quizzes
for your
site.
Complete
Login System
- With PHP +
MYSQL
Sata Hard
Drive Not
Recognized
By Windows -
WD 250gb
SATA hard
drive not
working
advertisement



Script Not Working :s - mysql errors



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE