Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

php help page goes blank

Posted on 2007-12-01
11
Medium Priority
?
180 Views
Last Modified: 2013-12-12
I am wondering why this page is comin up blank
Thanks
<?php
       require_once('con_info.php'); 
	session_start();
		
	if (!$_SESSION['user'] || !$_SESSION['pass']) {	
		if(isset($_REQUEST["submit"]))
        {
                // form submitted, do your update statements here...
                // Do your database update statements here
        }
        else 
        {
		
                $query = "SELECT * FROM survey where user='".$_SESSION['user']."'AND pass='".$_SESSION['pass']."'";
                // connect to your database
                
                $result = mysql_query($query);
                
                $row = mysql_fetch_array($result);
                
                //$querycity = "SELECT * FROM school";
                //$resultCity = mysql_query($querycity);
                
                
?>
<form action="<?php echo basename($_SERVER['PHP_SELF']) ; ?>" method="post" >
  <table width="502" border="0">
    
    <tr>
      <td colspan='2'>2. School Address:</td>
      <td><input name="scaddress" type="text" id="scaddress" value="<?php echo $row['scaddress']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>3. School Phone:</td>
      <td><input name="scphone" type="text" id="scphone" value="<?php echo $row['scphone']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>4. School Fax:</td>
      <td><input name="scfax" type="text" id="scfax" value="<?php echo $row['scfax']; ?>" size="31"></td>
    </tr>
    
    <tr>
      <td colspan='3'>
     <input type='submit' name='submit' id='submit' value='Submit' style='height: 40px; width: 200px; color: red; font:bold'></td>
    </tr>
    <tr>
      <td colspan='3'>&nbsp;</td>
    </tr>
  </table>
</form>
 
<?php 
 
        }
		}
?>

Open in new window

0
Comment
Question by:syedasimmeesaq
  • 6
  • 5
11 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390449
The cause is probably due to one of the following:

if (!$_SESSION['user'] || !$_SESSION['pass'])
one of these session variables are set, thus it doesn't go into the if statement (and you have no else statement)

if(isset($_REQUEST["submit"]))
You have submitted, thus it doesn't go into the else statment for this if claus, so you get a blank page.

To verify this, try the following code and see what prints out:
<?php
       require_once('con_info.php'); 
        session_start();
                
        if (!$_SESSION['user'] || !$_SESSION['pass']) 
        { 
                if(isset($_REQUEST["submit"]))
		        {
		        	echo "You submitted something...";
		                // form submitted, do your update statements here...
		                // Do your database update statements here
		        }
		        else 
		        {
		                
		                $query = "SELECT * FROM survey where user='".$_SESSION['user']."'AND pass='".$_SESSION['pass']."'";
		                // connect to your database
		                
		                $result = mysql_query($query);
		                
		                $row = mysql_fetch_array($result);
		                
		                //$querycity = "SELECT * FROM school";
		                //$resultCity = mysql_query($querycity);
                
                
?>
<form action="<?php echo basename($_SERVER['PHP_SELF']) ; ?>" method="post" >
  <table width="502" border="0">
    
    <tr>
      <td colspan='2'>2. School Address:</td>
      <td><input name="scaddress" type="text" id="scaddress" value="<?php echo $row['scaddress']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>3. School Phone:</td>
      <td><input name="scphone" type="text" id="scphone" value="<?php echo $row['scphone']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>4. School Fax:</td>
      <td><input name="scfax" type="text" id="scfax" value="<?php echo $row['scfax']; ?>" size="31"></td>
    </tr>
    
    <tr>
      <td colspan='3'>
     <input type='submit' name='submit' id='submit' value='Submit' style='height: 40px; width: 200px; color: red; font:bold'></td>
    </tr>
    <tr>
      <td colspan='3'>&nbsp;</td>
    </tr>
  </table>
</form>
 
<?php 
 
		        }
        }
        else 
        {
        	echo "First If statement's ELSE here";
        }
?>

Open in new window

0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390451
Correction on my statement:

if (!$_SESSION['user'] || !$_SESSION['pass'])
one of these session variables are set, thus it doesn't go into the if statement (and you have no else statement)

i was meaning:
if (!$_SESSION['user'] || !$_SESSION['pass'])
BOTH of these session variables are set, thus it doesn't go into the if statement (and you have no else statement)
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390471
yep that was the problem however my textarea is not getting populated from the database... my textfields are ok but textarea doesn't show any data. the textarea fields in data base are longtext 500
would you know what could be the problem
Thanks
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390476
I am using this to populate the textarea
 <textarea name='g2' type='text' id='g2' size='65' value='<?php echo $row['g2']; ?>'></textarea>
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390478
syedasimmeesag,

Correct me if I am wrong but I can't see any text areas in your code which is given?
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390480
change this to:
 <textarea name='g2' type='text' id='g2' size='65'><?php echo $row['g2']; ?></textarea>

All should work.
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390520
you are absolutely right. That worked. I didn't put the whole code so I don't confuse experts. I have one last question, why this dropdown box doesn't pull any values
<p><select name='f2' id='f2'>
          <option value='ABC '>1. ABC </option>
          <option value='EFG'>2. EFG</option>
          <option selected><?php echo $row['f2']; ?></option>
        </select></p></td>

I am trying to pull the value from field and then giving visitors an option to change it
Thanks
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 2000 total points
ID: 20390526
it works with a test value, so nothing wrong with your SELECT OPTION element, as demonstrated below.
Therefore it must be you $row['f2'] which does not contain anything? Try and echo this out and see if it outputs anything.
<p><select name='f2' id='f2'>
          <option value='ABC '>1. ABC </option>
          <option value='EFG'>2. EFG</option>
          <option selected><?php echo "test"; ?></option>
</select></p></td>

Open in new window

0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390553
Thank you ..yup there was no value in the field... I will be posting a same question about update in a while. If you get a chance please have a look at it as it is the same coding so it may be eaiser for you to troubleshool. I will post the link here
Thanks a lot.
0
 
LVL 9

Author Closing Comment

by:syedasimmeesaq
ID: 31412173
Excellent ansers...very quick and prompt response
Thank you nizsmo
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390556
no problem glad to help :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question