| | |
The page donot load completely untill I refresh the page
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hello All,
I have this strange problem ..
I am using require function twice in a single program to call two different programs.Each one of them has their own database connections.
The page doesnot execute completely untill I hit refresh.
It works as if those functions are executing one-after-the-other while I use refresh ...till then the HTML parts in the called functions appear but the mysql database values do not appear while leaving blank or previous data values in that place
Do I have to close the database connections at the end of each and every program?
I am getting the desired output only after hitting the refresh each time.
Can someone help me out with this.
Thanks in advance,
I have this strange problem ..
I am using require function twice in a single program to call two different programs.Each one of them has their own database connections.
The page doesnot execute completely untill I hit refresh.
It works as if those functions are executing one-after-the-other while I use refresh ...till then the HTML parts in the called functions appear but the mysql database values do not appear while leaving blank or previous data values in that placeDo I have to close the database connections at the end of each and every program?
I am getting the desired output only after hitting the refresh each time.
Can someone help me out with this.
Thanks in advance,
Last edited by Kavitha Butchi; Jul 2nd, 2008 at 3:35 am.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
•
•
•
•
try to use require once rather than require.
are they each connectiong to a different Db?
and yes as a security flaw you should close the connection when you are finished.
Hi casper_wang,
Thankyou for your time. As per your suggestions,
I changed each and every require() to require_once().
I used mysql_free_result( ) and mysql_close( ) at the end of every program.
Yes each are connecting to different databases.
Still the same problem persists.. any more suggestions will be appreciated.
Thank you.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
•
•
Join Date: May 2008
Posts: 67
Reputation:
Solved Threads: 3
Hello All,
The code is as following:
home.php
outlineget.php
This is all what the code is... reduced unnecessary length in the code.
All what happens here is ... am getting exact output only after refreshing the browser... if i do not refresh the browser the either NULL values are old data values will be present in the particular place. The problem is with OUTLINEGET.PHP part.... sometimes html part is getting displayed in it even before hitting the refresh but .. database values do not appear untill we hit refresh.
Any help
will be appreciated.
Thankyou all in advance.
The code is as following:
home.php
php Syntax (Toggle Plain Text)
<?php session_start(); ?> <?php if(isset( $_GET['userid'] )) { require_once('outlineget.php'); // calling another program which also has database connections. This is the one that is //executing after a REFRESH and which do not execute before using a REFRESH $userid = $_GET['userid']; $conn=mysql_connect( ) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db('db1') or die (mysql_error()); $sql = "SELECT * FROM registrations WHERE userid = '$userid'"; $result1 = mysql_query("$sql") or die("Invalid query: " . mysql_error()); $row = mysql_fetch_array( $result1 ); $displayname = $row['displayname']; $_SESSION['getdisplayname']=$displayname; mysql_select_db('db2') or die (mysql_error()); echo ' <html> <head> <title>profile</title> <style type="text/css"> // style code... </style> </head>'; $sql = "SELECT * FROM usersprofile WHERE displayname = '$displayname'"; $result = mysql_query("$sql") or die("Invalid query: " . mysql_error()); $row = mysql_fetch_array( $result ); $profnamedb = $row['profname']; echo ' <table id=content border="0" cellspacing="2" cellpadding="2" >'; echo '<tr ><td align="center"> <span ><font size=4 >'.$row['displayname'].'\'s'. '<font size=3>    Profile</font></span> </td></tr> <br/>'; //....table data is displayed ...no problem here if ($educationdb != NULL) echo '<tr><td><font face="arial"> <div class="signupFormLftcol">Education: </div> <div class="signupFormRgtcol" >'.$educationdb.'</div></td></tr>'; echo '</table>'; mysql_free_result($conn); mysql_close($conn); } // end of home.php
outlineget.php
php Syntax (Toggle Plain Text)
<?php session_start(); ?> <?php $conn=mysql_connect(".....") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db('db1') or die (mysql_error()); $displayname = $_SESSION['getdisplayname']; $sql = "SELECT profilepic FROM registrations WHERE displayname = '$displayname'"; $result = mysql_query("$sql") or die("Invalid query: " . mysql_error()); $row = mysql_fetch_array( $result ); $profpic = $row['profilepic']; $_SESSION['profpic'] = $profpic; echo ' <html> <head> <style type="text/css"> // ...style code... </style> </head> <body> <table width="99%" border="2" cellpadding="3" cellspacing="0" BGCOLOR=A9A9A9> <tr><td><font face="Arial" font size="2" align="center"><img src="pic1.gif"></td> </tr> <tr><td align="right"><font face="Arial" font size="2"><a href="home.php" class="uline">Home</a> | <a href="logout.php">Log out</a></td></tr> </table> <table width=95%> <tr><td > <table width="200" border="1" cellpadding="1" cellspacing="0"> <tr><td height="25" align="center" BGCOLOR="A9A9A9"><font face="arial" font size="4">'.$displayname.'</td></tr> // ... similar table data ...retreiving values from same database,table </td></tr> </table> </body> </html> '; mysql_free_result($conn); mysql_close($conn); ?>
This is all what the code is... reduced unnecessary length in the code.
All what happens here is ... am getting exact output only after refreshing the browser... if i do not refresh the browser the either NULL values are old data values will be present in the particular place. The problem is with OUTLINEGET.PHP part.... sometimes html part is getting displayed in it even before hitting the refresh but .. database values do not appear untill we hit refresh.
Any help
will be appreciated.Thankyou all in advance.
Last edited by Kavitha Butchi; Jul 4th, 2008 at 12:03 pm.
Kavitha
I Love My Indonesia.
I Love My Indonesia.
Try this:
home.php
outlineget.php
create new php:
config.php
If still having problems let me know.
home.php
PHP Syntax (Toggle Plain Text)
<?php require ('config.php'); // session_start(); $user->session_begin(); if(isset( $_GET['userid'] )) { require_once('outlineget.php'); // calling another program which also has database connections. This is the one that is //executing after a REFRESH and which do not execute before using a REFRESH $userid = $_GET['userid']; // $conn=mysql_connect( ) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db1) or die ("Unable to select database!"); $sql = 'SELECT * FROM ' . registrations . " WHERE userid = '$userid'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $displayname = $row['displayname']; $db->sql_freeresult($result); $_SESSION['getdisplayname'] = $displayname; mysql_select_db($db2) or die ("Unable to select database!"); echo ' <html> <head> <title>profile</title> <style type="text/css"> // style code... </style> </head>'; $sql = 'SELECT * FROM ' . usersprofile . " WHERE displayname = '$displayname'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $profnamedb = $row['profname']; $db->sql_freeresult($result); echo ' <table id=content border="0" cellspacing="2" cellpadding="2" >'; echo '<tr ><td align="center"> <span ><font size=4 >'.$row['displayname'].'\'s'. '<font size=3>    Profile</font></span> </td></tr> <br/>'; //....table data is displayed ...no problem here if ($educationdb != NULL) echo '<tr><td><font face="arial"> <div class="signupFormLftcol">Education: </div> <div class="signupFormRgtcol" >'.$educationdb.'</div></td></tr>'; echo '</table>'; } ?>
outlineget.php
PHP Syntax (Toggle Plain Text)
<?php require ('config.php'); // $conn=mysql_connect(".....") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db('db1') or die (mysql_error()); $displayname = $_SESSION['getdisplayname']; $sql = ' SELECT profilepic FROM ' . registrations ." WHERE displayname = '$displayname'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $profpic = $row['profilepic']; $_SESSION['profpic'] = $profpic; echo ' <html> <head> <style type="text/css"> // ...style code... </style> </head> <body> <table width="99%" border="2" cellpadding="3" cellspacing="0" BGCOLOR=A9A9A9> <tr><td><font face="Arial" font size="2" align="center"><img src="pic1.gif"></td> </tr> <tr><td align="right"><font face="Arial" font size="2"><a href="home.php" class="uline">Home</a> | <a href="logout.php">Log out</a></td></tr> </table> <table width=95%> <tr><td > <table width="200" border="1" cellpadding="1" cellspacing="0"> <tr><td height="25" align="center" BGCOLOR="A9A9A9"><font face="arial" font size="4">'.$displayname.'</td></tr> // ... similar table data ...retreiving values from same database,table </td></tr> </table> </body> </html> '; ?>
create new php:
config.php
PHP Syntax (Toggle Plain Text)
<?php // set database server access variables: $host = "host_name"; $user = "user_name"; //change this ti your user name $pass = "user_password"; // change this to your database password $db1 = "database_name"; // change tyhis to your database1 name $db2 = "database_name"; // change tyhis to your database2 name // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database ?>
Last edited by casper_wang; Jul 4th, 2008 at 9:50 pm.
If I helped in solving your issue please Add to "MY Reputation" and most important: "Mark as solved"
Well, Thats because,
$displayname is null here. The solution is to make sure $_SESSION['getdisplayname'] has a value before you include outlineget.php.
I hope its pretty clear. Eh ?
$_SESSION['getdisplayname']=$displayname; is being set after you include/require outlineget.php . That is, $_SESSION['getdisplayname'] is empty on the first run. So, outlineget.php will not display anything. •
•
•
•
$conn=mysql_connect(".....") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db('db1') or die (mysql_error());
$displayname = $_SESSION['getdisplayname'];
I hope its pretty clear. Eh ?
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
yep he is correct. try this code, must have been very tired last night when I played with this.
home.php
outlineget.php
create new php:
config.php
home.php
PHP Syntax (Toggle Plain Text)
<?php require ('config.php'); // session_start(); $user->session_begin(); if(isset( $_GET['userid'] )) { $userid = $_GET['userid']; mysql_select_db($db1) or die ("Unable to select database!"); $sql = 'SELECT * FROM ' . registrations . " WHERE userid = '$userid'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $displayname = $row['displayname']; $db->sql_freeresult($result); $_SESSION['getdisplayname'] = $displayname; require ('outlineget.php'); mysql_select_db($db2) or die ("Unable to select database!"); echo ' <html> <head> <title>profile</title> <style type="text/css"> // style code... </style> </head>'; $sql = 'SELECT * FROM ' . usersprofile . " WHERE displayname = '$displayname'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $profnamedb = $row['profname']; $db->sql_freeresult($result); echo ' <table id=content border="0" cellspacing="2" cellpadding="2" >'; echo '<tr ><td align="center"> <span ><font size=4 >'.$row['displayname'].'\'s'. '<font size=3>    Profile</font></span> </td></tr> <br/>'; //....table data is displayed ...no problem here if ($educationdb != NULL) echo '<tr><td><font face="arial"> <div class="signupFormLftcol">Education: </div> <div class="signupFormRgtcol" >'.$educationdb.'</div></td></tr>'; echo '</table>'; } ?>
outlineget.php
PHP Syntax (Toggle Plain Text)
<?php require ('config.php'); mysql_select_db('db1') or die (mysql_error()); $sql = ' SELECT profilepic FROM ' . registrations ." WHERE displayname = '$displayname'"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $profpic = $row['profilepic']; $_SESSION['profpic'] = $profpic; echo ' <html> <head> <style type="text/css"> // ...style code... </style> </head> <body> <table width="99%" border="2" cellpadding="3" cellspacing="0" BGCOLOR=A9A9A9> <tr><td><font face="Arial" font size="2" align="center"><img src="pic1.gif"></td> </tr> <tr><td align="right"><font face="Arial" font size="2"><a href="home.php" class="uline">Home</a> | <a href="logout.php">Log out</a></td></tr> </table> <table width=95%> <tr><td > <table width="200" border="1" cellpadding="1" cellspacing="0"> <tr><td height="25" align="center" BGCOLOR="A9A9A9"><font face="arial" font size="4">'.$displayname.'</td></tr> // ... similar table data ...retreiving values from same database,table </td></tr> </table> </body> </html> '; ?>
create new php:
config.php
PHP Syntax (Toggle Plain Text)
<?php // set database server access variables: $host = "host_name"; $user = "user_name"; //change this ti your user name $pass = "user_password"; // change this to your database password $db1 = "database_name"; // change tyhis to your database1 name $db2 = "database_name"; // change tyhis to your database2 name // open connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database ?>
If I helped in solving your issue please Add to "MY Reputation" and most important: "Mark as solved"
![]() |
Other Threads in the PHP Forum
- Previous Thread: how to insert a message board?
- Next Thread: PHP Paging and Page Number Nav
Views: 1719 | Replies: 10
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






