AnotherQuestion Posted August 23, 2009 Share Posted August 23, 2009 Im a newbie with PHP and am trying to write a script within Dreamweaver that quiries Mysql for 2 values. If they exist I want to send an email containing a random Password & the username. The User enters three values on a form. These are EMail Address, PostCode & AccNo. Then hits submit. The action then points to an new file checkexisting.php Dont think Im doing things the write way. I have written & tested the email script. It works with the exception of sending the username & password. the script goes somthing like this: <?php require_once('../../../Connections/AutoPart.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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; } } $colname_RsCustomer = "-1"; if (isset($_SESSION['AccountNo'])) { $colname_RsCustomer = $_SESSION['AccountNo']; } $colname1_RsCustomer = "-1"; if (isset($_SESSION['PCode'])) { $colname1_RsCustomer = $_SESSION['PCode']; } mysql_select_db($database_AutoPart, $AutoPart); $query_RsCustomer = sprintf("SELECT * FROM Customer WHERE KeyCode = %s AND PCode = %s", GetSQLValueString($colname_RsCustomer, "text"),GetSQLValueString($colname1_RsCustomer, "text")); $RsCustomer = mysql_query($query_RsCustomer, $AutoPart) or die(mysql_error()); $row_RsCustomer = mysql_fetch_assoc($RsCustomer); $totalRows_RsCustomer = mysql_num_rows($RsCustomer); If ($totalRows_RsCustomer <=1) then Goto Function Send_MailConfirm ; ?> <?Php Function Check_Account ($CheckAccount){} if (!function_exists("Send_MailConfirm")) { function Send_MailConfirm $to = $_SESSION['EMail']; $subject = 'Online account Set-up'; $PasswordStr = $_SESSION['Password']; $EmailStr = $_SESSION['EMail']; // the messgae body $message = ' <html> <head> <title>Online account Set-up</title> </head> <body> <p>Here are the details for you online login</p> <p> Your username is: $EmailStr </p> "\r\n" ; <P>Your password is: $PasswordStr </p> "\r\n" ; </body> </html> '; // When sending HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Account Setup <[email protected]>' . "\r\n"; // The next line sends the mail mail($to, $subject, $message, $headers);} ?> I keep getting an error Parse error: syntax error, unexpected T_STRING in /home/default/peakperformancewales.co.uk/user/htdocs/NewSite/SelfService/Scripts/CheckExisting.php on line 47 Link to comment https://forums.phpfreaks.com/topic/171545-call-a-fuction/ Share on other sites More sharing options...
rascle Posted August 23, 2009 Share Posted August 23, 2009 The error you said you are recieving means that somewhere in your code you have something like: echo' <form name='rhys'>'; which means that you have broken the string and then the code goes funny. The above can happen whilst using speech marks aswell. Link to comment https://forums.phpfreaks.com/topic/171545-call-a-fuction/#findComment-904642 Share on other sites More sharing options...
AnotherQuestion Posted August 23, 2009 Author Share Posted August 23, 2009 line 47 is: If ($totalRows_RsCustomer <=1) then Goto Function Send_MailConfirm ; i have no speech marks on that line. Link to comment https://forums.phpfreaks.com/topic/171545-call-a-fuction/#findComment-904644 Share on other sites More sharing options...
rascle Posted August 23, 2009 Share Posted August 23, 2009 Mmmm, i dunno then, sorry! Link to comment https://forums.phpfreaks.com/topic/171545-call-a-fuction/#findComment-904646 Share on other sites More sharing options...
AnotherQuestion Posted August 23, 2009 Author Share Posted August 23, 2009 Now got a new error after changing _Session to GET now got Parse error: syntax error, unexpected T_FUNCTION on line 59 which is the same line If ($totalRows_RsCustomer <=1) then Function Send_MailConfirm ; Link to comment https://forums.phpfreaks.com/topic/171545-call-a-fuction/#findComment-904653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.