Jump to content

need help with scripts

- - - - -

  • Please log in to reply
5 replies to this topic

#1
Artulo

Artulo

    Newbie

  • Members
  • Pip
  • 5 posts
I need help with login/register scripts? Which ones would you recommend? Everytime i try one and connect it to a database there is always an error! ALWAYS. I have wamp server 2.1 and php5. So what can the problem be? Maybe im using the wrong code ? oR?

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
What is the error? Normally the connect strings should be something like this on certain WAMPs:

"localhost, "root", ""

(server being local, user is root, default password is blank)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
Artulo

Artulo

    Newbie

  • Members
  • Pip
  • 5 posts
well, right now at the moment, these are some notices, and the script works :D But these annoying notices keep coming up whenever i login with the script or before i login. And i have fixed that connection with the database and so on. I am using a script from this site. Its at http://forum.codecal...-forms-php.html
( ! ) Notice: Undefined index: logged in C:\wamp\www\index.php on line 10
( ! ) Notice: Undefined index: userlogin in C:\wamp\www\index.php on line 51
( ! ) Notice: Undefined index: password in C:\wamp\www\index.php on line 5

#4
wwarren

wwarren

    Learning Programmer

  • Members
  • PipPipPip
  • 60 posts
Are you navigating to the page using the querystring variables? eg.

index.php?userlogin=myusername&password=mypassword

That should fix these

Quote

( ! ) Notice: Undefined index: userlogin in C:\wamp\www\index.php on line 51
( ! ) Notice: Undefined index: password in C:\wamp\www\index.php on line 5

As for the first one, it's just warning you that the session variable named "logged" isn't set to anything yet.

These aren't errors, they're just "Notices". They're something you should be aware of and you can turn them off by editing your php.ini file (left click the WAMPSERVER icon in your system tray > PHP > php.ini):

Quote

Hi. If you just want to hide the notices, please follow one of these:

Look for file "php.ini" in your local install of WAMP, usually inside folder "php".
Open it with your fav editor, then look for Error handling and logging section.

Set/change error_reporting to:
error_reporting = E_ALL & ~E_NOTICE

It will turn of the notice errors while still displaying warning errors.


Or, you may also add this code into your PHP program:
error_reporting(E_ALL & ~E_NOTICE);


Just as that simple. Hope it will help you.
Thanks.

(took that from Eliminate WAMP Server 2 Notices?)

FINALLY, you should always check if variables exist before attempting to use them using the
isset()
function in php. Then you wouldn't have this problem. I would always recommend better coding over disabling notices any day of the week.

Good luck.

#5
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
If you want to get rid of notices of undeclared variables, use error_reporting on the top of your webpage:

<?php

error_reporting(0);


/* ... your script ... */

?>

However: while developping your script you might want to keep error and notice reporting enabled for debugging purposes.

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

webcodez said:

If you want to get rid of notices of undeclared variables, use error_reporting on the top of your webpage:
Turning off errors is very silly (maybe you did not mean for this), your intended result is to turn off notices not errors:
error_reporting(E_ALL & ~E_NOTICE);
Or if you really wanted to, you could display nothing and still log them (recommended for production.)
error_reporting(E_ALL);
ini_set('display_errors', "0");
ini_set('log_errors', "1");

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users