Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hey zabberwan,

 

You can suppress the ob_end_flush error by prepending an @ symbol (it's the error-suppression operator) to the function call:

@ob_end_flush():

As for your other question, I would create a <div> at the point where you want any errors to display if any errors where detected. I haven't seen your validation code, but assuming any errors are added to an array variable named $errors:

if (!empty ($errors) { // if errors exist, create div for display
echo '<div style="color:red;margin:10px;">' . "\n";
foreach ($errors as $error) { // loop thru $errors array and print each error
       	echo "$error<br />\n";
}
echo "</div>\n\n"; // close div
} // end of $errors conditional

So if there are any errors, a <div> is inserted in your page and the rest of the content is pushed down accordingly. If no errors, no <div> is created.

  • Upvote 2
Link to comment
Share on other sites

Hi Paul,

 

That is exactly what I was looking for! Thank you so much.

 

As for the Output Buffering, I had already tried the suppression operator, but it did not remove it, but as I just rechecked the code, the error came from not starting the function in the header_include. So, I changed that, and prepended the suppressor for good measure, just in case.. :)

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

 

Have been busy with other things and now that I had some time to get back to finishing the registration/login system. I have finally been able to adapt it to my site and most things are functioning, but not very smoothly. So if anyone wants to lend me some further help, would really appreciate it.. Here are some of the problems am having:

 

1. The log out function just does not work. It shows alright, but on clicking it, it generates constantly the error, "Oops! This link appears to be broken.."

 

2. I tried to add a menu/list from the database (after making record sets) for Country and States. Dreamweaver 5 shows the register.php correctly in the browser, but when I try it on the remote server it gives an error:

 

[b]Warning[/b]:  require_once(../Connections/registrations.php) [[url="http://venture-wilderness.com/registrar/function.require-once"]function.require-once[/url]]: failed to open stream: No such file or directory in [b]/home/zabber1/public_html/venture-wilderness/registrar/register.php[/b] on line [b]1[/b]

[b]Fatal error[/b]:  require_once() [[url="http://venture-wilderness.com/registrar/function.require"]function.require[/url]]: Failed opening required '../Connections/registrations.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in [b]/home/zabber1/public_html/venture-wilderness/registrar/register.php[/b] on line [b]1[/b]

 

the main problems seem to be:

 

<?php require_once('../Connections/registrations_con.php'); ?> on line 1

 

mysql_select_db($database_registrations, $registrations);
$query_rsCountries = "SELECT * FROM countries ORDER BY countryName ASC";
$rsCountries = mysql_query($query_rsCountries, $registrations_con) or die(mysql_error());
$row_rsCountries = mysql_fetch_assoc($rsCountries);
$totalRows_rsCountries = mysql_num_rows($rsCountries);

mysql_select_db($database_registrations, $registrations);
$query_rsStates = "SELECT * FROM states ORDER BY stateName ASC";
$rsStates = mysql_query($query_rsStates, $registrations_con) or die(mysql_error());
$row_rsStates = mysql_fetch_assoc($rsStates);
$totalRows_rsStates = mysql_num_rows($rsStates);

 

I tried with the actual database settings on the remote site, but continue to get this error. If this error continues then as a last resort I can leave alone the Menu/List, but I need to have the fields.

 

3. The SESSION_COOKIE has a default life only for as long as the session which isn't very inviting and user friendly. Is there somewhere I can increase the time to live and add a few more parameters like username etc. ? (I concatenated first_name and last_name to "name" to save an entry field and changed the corresponding references in the code.)

 

4. How to direct users from one mode to the other (HTTP <=> HTTPS). I would like: User comes to HTTP site log in in HTTP and if new user then is directed to HTTPS to register and return to login in the HTTP mode. I know that one has to do this using "Headers", but am not sure how to exactly code it since we also have BASE.URL

 

5. Would also appreciate a little help to implement code snippet courtesy Paul Swanson:

 

if (!empty ($errors) { // if errors exist, create div for display
       echo '<div style="color:red;margin:10px;">' . "\n";
       foreach ($errors as $error) { // loop thru $errors array and print each error
               echo "$error<br />\n";
       }
       echo "</div>\n\n"; // close div
} // end of $errors conditional

 

I suppose with all that on board will make fine robust application! :)

 

 

Link to comment
Share on other sites

You've just posted five separate questions as one thread, which makes answering them impractical. How about creating individual posts for each question, so that people might be able to address them singularly? Also, I see you've taken the time to be the first person to use an image for your signature, but until you start including fundamental details, such as the version of PHP and MySQL in use (per the forum guidelines), I'm going to be disinclined to assist.

Link to comment
Share on other sites

 Share

×
×
  • Create New...