Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP - email & write to DB - no error, but no results
Old 12-13-2005, 12:23 PM PHP - email & write to DB - no error, but no results
croix's Avatar
Skilled Talker

Posts: 87
Name: Colin Roy
Location: Dallas, TX
Trades: 0
Im trying to convert a page that I have working already. It works now as a submit page that sends me an email with the information.

I want it to write that information to an Access database, as well as still send the email.

heres the PHP that was working for the email page.

Code:
<?php
ob_start();
include 'class.php';
if (isset($_POST['firstname'])) {
	$firstname = $_POST['firstname'];
	$lastname = $_POST['lastname'];
	$address1 = $_POST['address1'];
	$address2 = $_POST['address2'];
	$city = $_POST['city'];
	$state = $_POST['state'];
	$zip = $_POST['zip'];
	$email = $_POST['email'];
	$lubricant = $_POST['lubricant'];
	
	$msg = "Attention Sliquid! You have a new Sliquid sample request!

First Name = {$firstname}
Last Name = {$lastname}
Address = {$address1}
Address 2 = {$address2}
City = {$city}
State = {$state}
Zip = {$zip}
Email = {$email}
Lubricant Choice = {$lubricant}";

	ini_set(SMTP, "mail.sliquid.com");
	ini_set(smtp_port, 25);
	ini_set(sendmail_from, "sales@sliquid.com");
	$headers = "From: sales@sliquid.com\r\n";
	$headers .= "BCC: samples@sliquid.com\r\n";
	//mail(To, subject, content, header);
	$to = "samples@sliquid.com";
	$result  = mail($to, "Sliquid Sample Request", $msg, $headers);
	if( $result == 0 ) {
		echo "error <br>";
	}
	
	header("location: http://www.sliquid.com/verify2.htm"); 
}

ob_flush();

?>
I took some code from another page that i had working on my computer. It wrote to an Access DB, and displayed the results. So heres what I did to alter:

Code:
<?php
ob_start();
include 'class.php';
function Enter_New_Entry($FirstName,$LastName,$Address1,$Address2,$City,$State,$Zip,$Email,$LubricantChoice) {
 /*
        First, we create a connection to our ODBC source. This is done by creating
        a connection. Once this is done, we are returned an ODBC connection number.
        We use this number to use the ODBC functions within PHP.
    */

    $cnx = odbc_connect( 'customers' , 'Admin', '*****' );
    if (!$cnx) {
        Error_handler( "Error in odbc_connect" , $cnx );
    }
    $SQL_Exec_String = "Insert Into customers (FirstName, LastName, Address1, Address2, City, State, Zip, Email, LubricantChoice)
            Values ('$FirstName', '$LastName', '$Address1', '$Address2', '$City', '$State', '$Zip', '$Email', '$LubricantChoice')";

    $cur= odbc_exec( $cnx, $SQL_Exec_String );
    if (!$cur) {
        Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx );
    }

    odbc_close( $cnx);
}
Enter_New_Entry($FirstName,$LastName,$Address1,$Address2,$City,$State,$Zip,$Email,$LubricantChoice);


if (isset($_POST['firstname'])) {
	$firstname = $_POST['firstname'];
	$lastname = $_POST['lastname'];
	$address1 = $_POST['address1'];
	$address2 = $_POST['address2'];
	$city = $_POST['city'];
	$state = $_POST['state'];
	$zip = $_POST['zip'];
	$email = $_POST['email'];
	$lubricant = $_POST['lubricant'];
	
	$msg = "Attention Sliquid! You have a new Sliquid sample request!

First Name = {$firstname}
Last Name = {$lastname}
Address = {$address1}
Address 2 = {$address2}
City = {$city}
State = {$state}
Zip = {$zip}
Email = {$email}
Lubricant Choice = {$lubricant}";

	ini_set(SMTP, "mail.sliquid.com");
	ini_set(smtp_port, 25);
	ini_set(sendmail_from, "sales@sliquid.com");
	$headers = "From: sales@sliquid.com\r\n";
	$headers .= "BCC: samples@sliquid.com\r\n";
	//mail(To, subject, content, header);
	$to = "samples@sliquid.com";
	$result  = mail($to, "Sliquid Sample Request", $msg, $headers);
	if( $result == 0 ) {
		echo "error <br>";
	}
	
	header("location: http://www.sliquid.com/verify2.htm"); 
}

ob_flush();

?>
now, when i access the page in a browser, it just sits there blank. no error, no nothing.

any ideas????

Last edited by croix; 12-13-2005 at 04:31 PM..
croix is offline
Reply With Quote
View Public Profile Visit croix's homepage!
 
 
Register now for full access!
Old 12-13-2005, 01:05 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
One, you have to start ob_start() before anything else, plus you should at the very least dump the results of ob_start back to the screen so you can figure out what is going on.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-13-2005, 01:10 PM
croix's Avatar
Skilled Talker

Posts: 87
Name: Colin Roy
Location: Dallas, TX
Trades: 0
i moved ob_start() to the top, and nothing changed.

dont know what you mean by dump the results back to the screen, but since nothing comes up at all, the point is moot right now.
croix is offline
Reply With Quote
View Public Profile Visit croix's homepage!
 
Old 12-13-2005, 02:17 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Don't you need a call to ob_flush() at some point? Or else your output will just fill up the buffer on the server and never be sent to the browser?
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 12-13-2005, 03:38 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Quote:
Originally Posted by 0beron
Don't you need a call to ob_flush() at some point? Or else your output will just fill up the buffer on the server and never be sent to the browser?
That is what I was trying to say although I am never that clear.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-13-2005, 04:26 PM
croix's Avatar
Skilled Talker

Posts: 87
Name: Colin Roy
Location: Dallas, TX
Trades: 0
i tried putting

ob_flush();
and
ob_flush()

at the bottom( see code now), and theres still nothing on the screen at all.
croix is offline
Reply With Quote
View Public Profile Visit croix's homepage!
 
Reply     « Reply to PHP - email & write to DB - no error, but no results
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16548 seconds with 12 queries