[SOLVED] When accessing database returns blank page

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

[SOLVED] When accessing database returns blank page

Post by anthony88guy »

When I test the script the page comes up. It works correctly if you try and register with a already registered username. But when you try adding a user to the database you get a blank page. I have checked the database nothing gets added. A registered user is: test. You can try it at
Last edited by anthony88guy on Thu May 12, 2005 5:49 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check the error logs on the server, an error/notice/whatever may have written there instead of being displayed.
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

where could i access the server logs? Did you try it out?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there's no way for us to "try it out."

If you have Cpanel, there's a button called "Error Log." Other control panels have similar buttons in various places.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Or insert the following lines into your Php.

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
This should display any php errors or warnings. (Coding not logic)
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

I dont think you guys understand what i mean. I tested out where my problems begin by using print at different stages in the code. The print function stops working at line: 31. So I believe that their is something going on their thats not Correct. My objective is to make a register script that checks:

1) Matching passwords
2) Any blank feilds
3) If username is taken
4) Register account

I have some ideas about how to write some of the code. Hopefully it will work. My old register script worked, but it didn't check for registered usernames.
Last edited by anthony88guy on Thu May 12, 2005 6:04 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

ERROR - Please Try Again Later
sure doesn't look like a blank page to me.. not to mention all the advertising junk..
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

I added the ERROR - Please Try Again, in my script before line: 31, and the advertisments come from my hosting. I am using firefox and it blocks all that.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

CoderGoblin wrote:Or insert the following lines into your Php.

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
This should display any php errors or warnings. (Coding not logic)
have you tried this?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

Try this query...

Code: Select all

$result = mysql_query("INSERT INTO users (user, pass, strikeaction, armysize, statid) VALUES('".$username."', '".$pass1."', '".$strikeaction."', '".$armysize."', '".$statid."')") or die(mysql_error());
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

Phenom wrote:
CoderGoblin wrote:Or insert the following lines into your Php.

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
This should display any php errors or warnings. (Coding not logic)
have you tried this?
Yes, I have tried that. Nothing turns up. I will try your query infolock.

EDIT: Same result infolock. Am I using mysql_query() wrong on line 31?
EDIT2: I uploaded my old register.php that worked. Only thing it doesnt check for registered usernames.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

no your query was correct i just didn't know how you setup your id field so i omitted it from the query itself. was just a test more than anything else.

however, in your check this might cause a problem :

Code: Select all

if($username !== "" && $pass1 !== "" && $pass2 !== "" && $statid !== "" && $strikeaction !== "" && $armysize !== "" && $pass1 == $pass2){
try this instead...

Code: Select all

if($username != "" && $pass1 != "" && $pass2 != "" && $statid != "" && $strikeaction != "" && $armysize != "" && $pass1 == $pass2){
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

Post by anthony88guy »

infolock wrote:no your query was correct i just didn't know how you setup your id field so i omitted it from the query itself. was just a test more than anything else.

however, in your check this might cause a problem :

Code: Select all

if($username !== "" && $pass1 !== "" && $pass2 !== "" && $statid !== "" && $strikeaction !== "" && $armysize !== "" && $pass1 == $pass2){
try this instead...

Code: Select all

if($username != "" && $pass1 != "" && $pass2 != "" && $statid != "" && $strikeaction != "" && $armysize != "" && $pass1 == $pass2){
Correct me if i am wrong but DONT you need to compare them using ==, if you use = you are setting the variable. I am a noob so i could be wrong. I also had another thought that it could be my hosting because it is very flaky and i have rewritten the same code like 5 times in different ways, all the same result. I have free hosting and they seem to have more down time then uptime. I know its not the right place but if you know any good quailty hosting with PHP (duh) and good amount of space and bandwidth please tell me.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

anthony88guy wrote:Correct me if i am wrong but DONT you need to compare them using ==, if you use = you are setting the variable.
when alone, yes, that's true. But with the negation (!) it's a completely different operator. I can understand the confusion, since both ! and = are operators seperately, plus they are a different operator together.
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

!= checks for inequality (0!='' returns false)
!== checks for inequality and type (0!=='' returns true)
Post Reply