voxanBoxer Posted January 16, 2007 Share Posted January 16, 2007 >:( I have been an ASP programmer for 10 years. I am trying to learn PHP and get away from ASP. I have struggled for days to get things to work in PHP that would have taken me minutes in ASP.I have a page that uses an include.It took a day and a half to get a connection to mysql to work (literally 8 lines of code). But I finally got it to work and return a value from the database.I then moved on to $_SESSION which I could only get to return the session data on the page that set the session data. Once I went to another page, $_SESSION is blank.After scouring the internet for a solution I ran across one. I tried to implement it but it didn't work. The result was a blank page. So I reverted back to my "working" code and the page is still blank. I can't get it to do anything. Even this won't display:<?phpecho "Hello World!";?>The above code produces a blank page as well. Again this page is an include file. If I remove the include, the HTML on the page displays. If I include the above code as an include the page is blank. If I open the above code by itself it is still a blank page.It seems that as soon as I ran "!isset" in my code, PHP stopped working COMPLETELY. Even though I took it back out PHP is still broken.What is going on? I could have finished the site in ASP by now. I still want to do it in PHP but this is frustrating!!!!!! >:( Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/ Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 if I make a new page with this code:<?phpecho "Hello World!";?>It works. But the include page comes up blank.Maybe it is a caching issue.Nope, I cleared the cache and same result. Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162108 Share on other sites More sharing options...
JJohnsenDK Posted January 16, 2007 Share Posted January 16, 2007 For me it sounds like your installation is f***ed.try this site:[url=http://www.apachefriends.org/en/xampp.html]http://www.apachefriends.org/en/xampp.html[/url]Its a very cool program that installs all you need for php and mysql to work correctly.You also get a mail server and ohter stuff installed.Its very nice.Let me know if there still are problems after installation.JJohnsenDK Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162109 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 I am on a shared server. I can't install anything Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162115 Share on other sites More sharing options...
Zane Posted January 16, 2007 Share Posted January 16, 2007 [quote]<?phpecho "Hello World!";?>[/quote][quote]the include page comes up blank.[/quote]I don't see any include statements in the code above. Where's the code where you're including a page Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162121 Share on other sites More sharing options...
Psycho Posted January 16, 2007 Share Posted January 16, 2007 What is the code you are using to include the page? As for the sessions problem, are you usining session_start() on every page?Edit: Zanus, stop looking at me like that! Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162126 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 include('dbconn.php'); // Connect to the database to retrieve challenge response $cxn = mysql_connect($mysql_HOST,$mysql_USER,$mysql_PASS); // Connect to server $db_selected = mysql_select_db($mysql_DB, $cxn); // Select the database $result = mysql_query("SELECT * FROM Secure"); // Perform MySQL SELECT statement if ($result){ // Make sure select statement worked $row = mysql_fetch_array($result); // Get database values in array session_start(); // Start the session $_SESSION['avar'] = $row['id']; // Set the avar value $_SESSION['bvar'] = $row['email']; // Set the bvar value } like I said, that code worked fine until I added:if(!isset($_SESSION['avar'])){ $_SESSION['avar'] = $row['id'];}That code produced a blank page. so I reverted back to the other code and I still get a blank page. Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162168 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 However, I think everyone is missing the point.I changed the include page to have this code, and only this code:echo "Hello World!";and it is still a blank page. So it doesn't make a difference what the code is. Anycode makes it blank whereas it was working before I used isset. Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162171 Share on other sites More sharing options...
JJohnsenDK Posted January 16, 2007 Share Posted January 16, 2007 session_start(); should always be at the very top of your code... Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162173 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 [quote author=JJohnsenDK link=topic=122665.msg506248#msg506248 date=1168971657]session_start(); should always be at the very top of your code...[/quote]I tried that tooBUT, like I said, the include page, even with echo "Hello World!"; is blank Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162178 Share on other sites More sharing options...
JJohnsenDK Posted January 16, 2007 Share Posted January 16, 2007 okayim i getting this right:you write:[code]<?phpecho "Hello world";?>[/code]in test.phpyou test it and it works?then you try this:[code]<?phpinclude("test.php");if(something){ echo "this";}?>[/code]and notthing happens? Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162184 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 To make it easier I moved all the code from the include file into the index.php file (I chaged to <edit> to remove sensitive data:-----------------------------------------------------------<?phpsession_start();$mysql_HOST = "<edit>"; $mysql_USER = "<edit>"; $mysql_PASS = "<edit>";$mysql_DB = "<edit>"; $cxn = mysql_connect($mysql_HOST,$mysql_USER,$mysql_PASS);$db_selected = mysql_select_db($mysql_DB, $cxn); $result = mysql_query("SELECT * FROM Secure"); if ($result){ $row = mysql_fetch_array($result); $_SESSION['<edit>'] = $row['<edit>']; $_SESSION['<edit>'] = $row['<edit>'];} ?>-----------------(continued in next post) Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162193 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 This produces a blank page!NOW, I comment out EVERYTHING!!!!!! to look like this:-----------------------------------------------------------<?php//session_start();//$mysql_HOST = "<edit>"; //$mysql_USER = "<edit>"; //$mysql_PASS = "<edit>";//$mysql_DB = "<edit>"; //$cxn = mysql_connect($mysql_HOST,$mysql_USER,$mysql_PASS);//$db_selected = mysql_select_db($mysql_DB, $cxn); //$result = mysql_query("SELECT * FROM Secure"); //if ($result){ //$row = mysql_fetch_array($result); //$_SESSION['<edit>'] = $row['<edit>']; //$_SESSION['<edit>'] = $row['<edit>'];//} ?>-----------------(continued in next post) Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162197 Share on other sites More sharing options...
Psycho Posted January 16, 2007 Share Posted January 16, 2007 Looking at the code you posted (which would have been helpful in your first post) you would get no output if the query failed. Add some error handling to your query to see if any errors are produced:[code]$result = mysql_query("SELECT * FROM Secure") or die (mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162198 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 The resulting page is STILL blank.I remove the <?php & ?> and the page displays the html Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162199 Share on other sites More sharing options...
Psycho Posted January 16, 2007 Share Posted January 16, 2007 [quote author=voxanBoxer link=topic=122665.msg506274#msg506274 date=1168972908]The resulting page is STILL blank.I remove the <?php & ?> and the page displays the html[/quote]If you comment out everything wouldn't you expect a blank page? What do you mean "I remove the <?php & ?> and the page displays the html". What HTML is displayed? Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162202 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 The HTML below the php code<?phpecho "Hello World!<P>";?><html><body>Hello World!</body></html>We can all agree that the expected result should be:Hello World!Hello World!correct? I get a blank page.If I comment out echo "Hello World!<P>"; in the php code the expected result would be:Hello World!correct? Well the page is still blank! If I take out all the PHP tags the expected result would be:Hello World!correct? And in fact that is what I get. BUT with php tags in the page, I get nothing.Having said all that. It only happens on this page. PHP works on other pages. AND USED TO WORK ON THIS PAGE. Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162206 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 For S**ts&Giggles I added$result = mysql_query("SELECT * FROM Secure") or die (mysql_error());and I still get a blank page Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162209 Share on other sites More sharing options...
Zane Posted January 16, 2007 Share Posted January 16, 2007 put this at the very beginning of your code and tell us if it returns anythingerror_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162215 Share on other sites More sharing options...
voxanBoxer Posted January 16, 2007 Author Share Posted January 16, 2007 I tried that before I posted this thread and got nothing.BUT, it is now working again. Nothing has changed it just started working again. There must have been something wrong with my hosting company's server. Quote Link to comment https://forums.phpfreaks.com/topic/34432-why-doesnt-php-work/#findComment-162219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.