PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > Update fails
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Update fails

Réponse
 
LinkBack Outils de la discussion
Vieux 17/07/2007, 03h42   #1
Kevin Raleigh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Update fails

The following code seems to be failing. Can you check my logic?
I am using this //>> notation in the body of the code to indicate my
questions and
comments
$check = mysql_query("SELECT * FROM user WHERE id = '$userID'")or die("query
failed!");

//>> Gives error if user dosen't exist
//>> this should read if($check2==0) but it dosen't work??
//>>I always get the die message that user does not exist in the db
//>>I checked the db and the user is in the db

$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database. ');
}



while($info = mysql_fetch_array( $check )){
$dbSecureID = stripslashes($info['secureID']);
$fName = stripslashes($info['fName']);
$lName = stripslashes($info['lName']);
//gives error if the password is wrong
}
if ($secureID != $dbSecureID) {

//>>this works but I can't figure how my userId fails and this passes?

die('This user has not registered yet!');
} else{

//>> why would this code fail it looks basic enough??
mysql_query("UPDATE user SET confirmIDFlag=1 WHERE id=$userID");

insight appreciated
thank you
Kevin Raleigh


  Réponse avec citation
Vieux 17/07/2007, 03h51   #2
Rik
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Update fails

On Tue, 17 Jul 2007 04:42:30 +0200, Kevin Raleigh <kraleigh@sbcglobal.net>
wrote:

> The following code seems to be failing. Can you check my logic?
> I am using this //>> notation in the body of the code to indicate my
> questions and
> comments
> $check = mysql_query("SELECT * FROM user WHERE id = '$userID'")or
> die("query
> failed!");


What is in $userID? Try to echo the query before performing it.



--
Rik Wasmus
  Réponse avec citation
Vieux 17/07/2007, 04h25   #3
Kevin Raleigh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Update fails

I have user id from the url string. sorry forgot to mention it.
http://www.myWebSite.org/validate?id=154&code=Ogtidw

$userID = $_GET["id"];
$secureID = $_GET["code"];

Why would the update fail?
Did I code it correctly?

Thank You
Kevin Raleigh

"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
newsp.tvk8wiczqnv3q9@metallium...
On Tue, 17 Jul 2007 04:42:30 +0200, Kevin Raleigh <kraleigh@sbcglobal.net>
wrote:

> The following code seems to be failing. Can you check my logic?
> I am using this //>> notation in the body of the code to indicate my
> questions and
> comments
> $check = mysql_query("SELECT * FROM user WHERE id = '$userID'")or
> die("query
> failed!");


What is in $userID? Try to echo the query before performing it.



--
Rik Wasmus


  Réponse avec citation
Vieux 17/07/2007, 05h00   #4
Kevin Raleigh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Update fails

How do you sanitize variables to prevent sql injections?

thank you
Kevin Raleigh

"Norman Peelman" <npeelman@cfl.rr.com> wrote in message
news:469c3ba5$0$8018$4c368faf@roadrunner.com...
> Kevin Raleigh wrote:
> > I have user id from the url string. sorry forgot to mention it.
> > http://www.myWebSite.org/validate?id=154&code=Ogtidw
> >
> > $userID = $_GET["id"];
> > $secureID = $_GET["code"];
> >
> > Why would the update fail?
> > Did I code it correctly?
> >
> > Thank You
> > Kevin Raleigh
> >
> > "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
> > newsp.tvk8wiczqnv3q9@metallium...
> > On Tue, 17 Jul 2007 04:42:30 +0200, Kevin Raleigh

<kraleigh@sbcglobal.net>
> > wrote:
> >
> >> The following code seems to be failing. Can you check my logic?
> >> I am using this //>> notation in the body of the code to indicate my
> >> questions and
> >> comments
> >> $check = mysql_query("SELECT * FROM user WHERE id = '$userID'")or
> >> die("query
> >> failed!");

> >
> > What is in $userID? Try to echo the query before performing it.
> >
> >
> >

>
> Remove the quotes from around $userID in the query... you don't need
> them for numbers, only strings (generally speaking). And sanitize your
> variables to prevent SQL Injections.
>
> Norm



  Réponse avec citation
Vieux 17/07/2007, 05h11   #5
Kevin Raleigh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Update fails

I tried removing the quotes from the query:
$check = mysql_query("SELECT * FROM user WHERE id = $userID")or die("query
failed!");

and it comes back with my die message "query failed";

can you advise further?

Kevin Raleigh
"Kevin Raleigh" <kraleigh@sbcglobal.net> wrote in message
news:X6CdnaYASeZRoAHbnZ2dnUVZ_jSdnZ2d@giganews.com ...
> How do you sanitize variables to prevent sql injections?
>
> thank you
> Kevin Raleigh
>
> "Norman Peelman" <npeelman@cfl.rr.com> wrote in message
> news:469c3ba5$0$8018$4c368faf@roadrunner.com...
> > Kevin Raleigh wrote:
> > > I have user id from the url string. sorry forgot to mention it.
> > > http://www.myWebSite.org/validate?id=154&code=Ogtidw
> > >
> > > $userID = $_GET["id"];
> > > $secureID = $_GET["code"];
> > >
> > > Why would the update fail?
> > > Did I code it correctly?
> > >
> > > Thank You
> > > Kevin Raleigh
> > >
> > > "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
> > > newsp.tvk8wiczqnv3q9@metallium...
> > > On Tue, 17 Jul 2007 04:42:30 +0200, Kevin Raleigh

> <kraleigh@sbcglobal.net>
> > > wrote:
> > >
> > >> The following code seems to be failing. Can you check my logic?
> > >> I am using this //>> notation in the body of the code to indicate my
> > >> questions and
> > >> comments
> > >> $check = mysql_query("SELECT * FROM user WHERE id = '$userID'")or
> > >> die("query
> > >> failed!");
> > >
> > > What is in $userID? Try to echo the query before performing it.
> > >
> > >
> > >

> >
> > Remove the quotes from around $userID in the query... you don't need
> > them for numbers, only strings (generally speaking). And sanitize your
> > variables to prevent SQL Injections.
> >
> > Norm

>
>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h41.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13025 seconds with 13 queries