Page 1 of 1

Why doesn't this work?

Posted: Thu Jul 16, 2009 12:02 pm
by ChrisGraser
Well I have been doing this for about a year now and I am just starting to dig deeper into Php on a daily basis. That being said I have no idea why this isn't working.

Code: Select all

 
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname = "mysql.last7studios.com";
$database = "last7studios";
$username = "chris";
$password = "*********";
$last7 = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); 
 
mysql_select_db($database,$last7);
 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
$server_call = mysql_query("SELECT email_id, emails, username_email FROM internal_email") or die(mysql_error());
$new_row = mysql_fetch_assoc($server_call);
do {
$list = $new_row['username_email'];
$to_line = $new_row['emails'];
$username = $list;
$query = mysql_query("SELECT  project_names.project_name, users.username, tasks.task_description, tasks.status, tasks.task_priority, tasks.task_id, tasks.project_id, tasks.task FROM users, project_names, tasks WHERE users.username = '$username' AND tasks.project_id = project_names.project_id AND tasks.user_id = users.user_id ORDER BY tasks.status DESC") or die(mysql_error());
$task_row = mysql_fetch_assoc($query);
$query_pn = mysql_query("SELECT * FROM project_names WHERE project_id = '$id'") or die(mysql_error());
$project_row = mysql_fetch_assoc($query_pn);
if(mysql_num_rows > 0){
$to = $to_line;
$subject = "you have tasks!";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$body = "$status";
$body .= "$priority";
$body .= "$name_pro";
$body .= "\n";
do{
    $body .= '<br />';
    $body .= $task_row['username'];
    $body .= '<br />';
    $body .= $task_row['status'];
    $body .= '<br />';
    $body .= $task_row['task_priority'];
    $body .= '<br />';
    $body .= $task_row['project_name'];
    $body .= '<br />';
    $body .= $task_row['task'];
    $body .= '<br />';
    $body .= '<br />';
}
while($task_row = mysql_fetch_assoc($query));
 
 
if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
 
};
}while($new_row = mysql_fetch_assoc($server_call));
 
 
?>
 
<?php echo $_SERVER['DOCUMENT_ROOT'];?>
<?php echo $rows_stuff ;?>
 
 
Any help would be greatly appreciated

Thank you in advance

Re: Why doesn't this work?

Posted: Thu Jul 16, 2009 12:13 pm
by califdon
You haven't said what doesn't work. Does it produce an error? Does it produce a blank screen? Does it produce a page, but something is wrong on the page? What?

Re: Why doesn't this work?

Posted: Thu Jul 16, 2009 12:19 pm
by ChrisGraser
lol good point.

When the file executes on the server all it does is display -/home/last7/last7studios.com
the file is not running the email function. If it was it would print 3 times -"Message successfully sent!"

That is my problem.

Re: Why doesn't this work?

Posted: Thu Jul 16, 2009 12:34 pm
by spider.nick
ChrisGraser wrote:lol good point.

you can view the page at http://www.last7studios.com/admin/do_file.php

When the file executes on the server all it does is display -/home/last7/last7studios.com
the file is not running the email function. If it was it would print 3 times -"Message successfully sent!"

That is my problem.
Check your line that says:

Code: Select all

if(mysql_num_rows > 0)
If that is not true, you never mail anything.

I would check your query, possibly via phpMyAdmin.

Nick

Re: Why doesn't this work?

Posted: Thu Jul 16, 2009 1:07 pm
by ChrisGraser
spider.nick wrote:
ChrisGraser wrote:lol good point.

you can view the page at http://www.last7studios.com/admin/do_file.php

When the file executes on the server all it does is display -/home/last7/last7studios.com
the file is not running the email function. If it was it would print 3 times -"Message successfully sent!"

That is my problem.
Check your line that says:

Code: Select all

if(mysql_num_rows > 0)
If that is not true, you never mail anything.

I would check your query, possibly via phpMyAdmin.

Nick
That was it, I was trying to build an if statement and left a piece of it in there.

Thanks you

Re: Why doesn't this work?

Posted: Fri Jul 17, 2009 10:52 am
by spider.nick
No problem; I am glad I could be of assistance.

Nick