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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

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.