Jump to content

[SOLVED] daft error, varible error


wmguk

Recommended Posts

I get a blank page so it must be a bad php code, however im looking at it and just cant see it?

 

while($row = mysql_fetch_array($result)) 
{ 
$email = $row['email']; 
$groom_firstname = $row['groom_firstname']; 
$groom_surname = $row['groom_surname']; 
$bride_firstname = $row['bride_firstname']; 
$bride_surname = $row['bride_surname']; 

if ($groom_firstname == 'X') 
{  
  $title = "$row['bride_firstname'] . ' ' . $row['bride_surname']";
} 
  else
{
  $title = "$row['bride_firstname'] . ' ' . $row['bride_surname'] . ' and ' . $row['groom_firstname'] . ' ' . $row['groom_surname']"; 

Link to comment
Share on other sites

hey,

 

i dont get any error at all, just a blank white page.

 

<?php

$login = $_GET['login'];

//Make Connection

include "scripts/connection.php"; 
if (!$con) 
{ 
die( 'Could not connect: ' . mysql_error() ); 
}
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE login = '$login'");

while($row = mysql_fetch_array($result)) 
{ 
$email = $row['email']; 
$groom_firstname = $row['groom_firstname']; 
$groom_surname = $row['groom_surname']; 
$bride_firstname = $row['bride_firstname']; 
$bride_surname = $row['bride_surname']; 

if ($groom_firstname == 'X') 
{  
  $title = "$row['bride_firstname'] . ' ' . $row['bride_surname']";
} 
  else
{
  $title = "$row['bride_firstname'] . ' ' . $row['bride_surname'] . ' and ' . $row['groom_firstname'] . ' ' . $row['groom_surname']"; 

?>

 

you can then

<?php echo $title ; ?>

Link to comment
Share on other sites

1. well you should get errors with that code seeing as you are missing to curly braces at the end, so im assuming this isnt the whole code.

 

2. Are you sure that $_GET['login'] actually equals anything, in which case your query and while loop would both not function.

 

3. why do you set $row['bride_firstname'] to $bride_firstname yet you still use $row['bride_firstname']. This isnt wrong it just seems pointless

 

~ Chocopi

Link to comment
Share on other sites

ok, now have this:

 

<?php

$login = $_GET['login'];

//Make Connection

include "scripts/connection.php"; 
if (!$con) 
{ 
die( 'Could not connect: ' . mysql_error() ); 
}
mysql_select_db($db, $con); 

$result = mysql_query("SELECT * FROM album WHERE login = '$login'");

while($row = mysql_fetch_array($result)) 
{ 
$email = $row['email']; 
$groom_firstname = $row['groom_firstname']; 
$groom_surname = $row['groom_surname']; 
$bride_firstname = $row['bride_firstname']; 
$bride_surname = $row['bride_surname']; 

if ($groom_firstname == 'X') 
{  
  $title = "'$bride_firstname' '$bride_surname'";
} 
  else
{
  $title = "'$bride_firstname' '$bride_surname' and '$groom_firstname' '$groom_surname'"; 

?><html><link href="http://demo.iwphoto.co.uk/styles.css" rel="stylesheet" type="text/css" />
<?php
$mime_boundary = "IW Photo".md5(time());

# -=-=-=- MAIL HEADERS

$to = "$email";
$subject = "Your album is now live";

$headers = "From: Imagine Wedding Photography <info@iwphoto.co.uk>\n";
$headers .= "Reply-To: Imagine Wedding Photography <info@iwphoto.co.uk>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";

# -=-=-=- HTML EMAIL PART

$message .= "--$mime_boundary\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";

$message .= "<html>\n";
$message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:14px; color:#666666;\">\n"; 
$message .= "<table width='800' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td height='80' align='left' valign='top' background='http://demo.iwphoto.co.uk/images/top.jpg'><p> </p></td></tr><tr><td align='left' valign='top' background='http://demo.iwphoto.co.uk/images/middle.jpg'>";
$message .= "<table width='800' border='0' cellspacing='0' cellpadding='0'><tr><td width='20'> </td>";
$message .= "<td class='main'><p>Dear ";
$message .= "<p>Dear $title,";
$message .= "<p>We are please to announce that your album has been made live now.</p>";
$message .= "<p>Please click <a href='http://demo.iwphoto.co.uk/emailgallery.php?login=$login'>HERE</a> to view your album. </p>";
$message .= "<p>You can also now tell all your family and friends about your new album by clicking HERE. </p></td><td width='20'> </td></tr></table></td></tr>";
$message .= "<tr><td align='left' valign='top' background='http://demo.iwphoto.co.uk/images/bottom.jpg'> </td></tr></table>";
$message .= "</body>\n";
$message .= "</html>\n";

# -=-=-=- FINAL BOUNDARY

$message .= "--$mime_boundary--\n\n";

# -=-=-=- SEND MAIL

$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed"; 
echo $to ; 
}
?>

Link to comment
Share on other sites

try replacing your if and else with this

 


if ($groom_firstname == 'X') 
{  
  $title = $row['bride_firstname'] . ' ' . $row['bride_surname'];
} 
  else
{
  $title = $row['bride_firstname'] . ' ' . $row['bride_surname'] . ' and ' . $row['groom_firstname'] . ' ' . $row['groom_surname'];

Link to comment
Share on other sites

try replacing your if and else with this

 


if ($groom_firstname == 'X') 
{  
  $title = $row['bride_firstname'] . ' ' . $row['bride_surname'];
} 
  else
{
  $title = $row['bride_firstname'] . ' ' . $row['bride_surname'] . ' and ' . $row['groom_firstname'] . ' ' . $row['groom_surname'];

 

nope, still nothing, just a white page - it must be a php coding error, i know the login variable is being passed through it...

Link to comment
Share on other sites

From what I can see you still havent closed your while loop, but if its not giving an error ??? then i guess it does not matter.

 

Can you echo $login to make sure it has a value:

 

$login = $_GET['login'];
echo $login;

 

Also, can you add

 

or die(mysql_error());

 

After you query

 

~ Chocopi

Link to comment
Share on other sites

From what I can see you still havent closed your while loop, but if its not giving an error ??? then i guess it does not matter.

 

Can you echo $login to make sure it has a value:

 

$login = $_GET['login'];
echo $login;

 

Also, can you add

 

or die(mysql_error());

 

After you query

 

~ Chocopi

 

the $login is working, basically I am going to the script via "http://www.website.co.uk/email.php?login=demo"

 

and added the or die, but still white

Link to comment
Share on other sites

From what I can see you still havent closed your while loop, but if its not giving an error ??? then i guess it does not matter.

~ Chocopi

 

also, right at the bottom of the original script there is the last while closer..

 

is that the right place, its after the email gets sent

Link to comment
Share on other sites

can you replace

 

while($row = mysql_fetch_array($result))

 

with

 

while($row = mysql_fetch_assoc($result))

 

As on my browser mysql_fetch_array doesnt actually work, so it might be the same for you

 

~ Chocopi

Link to comment
Share on other sites

also, right at the bottom of the original script there is the last while closer.

 

isnt that the one that closes this else statement

 

<?php

if ($groom_firstname == 'X') 
{  
  $title = "'$bride_firstname' '$bride_surname'";
} 
  else
{ // this one is the one closed at the bottom of the page
  $title = "'$bride_firstname' '$bride_surname' and '$groom_firstname' '$groom_surname'";

?>

Link to comment
Share on other sites

ah ha,

 

got it - you were right, i was missing the }

 

if ($groom_firstname == 'X') 
{  
 $title = $row['bride_firstname'] . ' ' . $row['bride_surname'];
} 
 else
{
 $title = $row['bride_firstname'] . ' ' . $row['bride_surname'] . ' and ' . $row['groom_firstname'] . ' ' . $row['groom_surname'];
} // This one was missing, its now working woo hoo, just need to get the page background to go grey now 

thank you guys !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.