Jacek's maillinglist tutorial

Post here if you need help with SQL.
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Jacek's maillinglist tutorial

Post by Fidbeck »

Hey

I'm introdicing myself to sql and used Jacek's mailing list to give it a try, the problem is that I'm not being able to connect to the database :S don't know what info to use except fot the mysql_select_db because I only have one lol


i'm using 000webhost.com (I use it because its free.
Could you guys help me out here?
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

I would suggest that you don't use 000webhost.
They disable your account if you send too many emails at once.

And we need to see what you connecting code is, so just paste that in :) (but remove your password)
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

that would be
<?php
 //param1-link, param2-utilisador, param3-palvara pass
mysql_connect('don\'t know what to use here', 'myuser', 'mypass');
// escolha da base de dados
mysql_select_db('a5510829_mailing'); 

$path = dirname(__FILE__);

include("{$path}/inc/mail.inc.php");
?>
that's too bad :S i'm not willing to pay for one host :S
can you suggest one that doesn'0t delete my acc? thanks
User avatar
EcazS
Posts: 789
Joined: Fri May 06, 2011 5:29 pm

Re: Jacek's maillinglist tutorial

Post by EcazS »

You're supposed to get that info from your host. The first parameter is 9/10 times "localhost" though.
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

What I get is this
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a5510829_fidbeck'@'localhost' (using password: YES) in /home/a5510829/public_html/mailing_list/core/init.inc.php on line 3

Free Web Hosting

PHP Error Message

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'a5510829'@'localhost' (using password: NO) in /home/a5510829/public_html/mailing_list/core/init.inc.php on line 5

Free Web Hosting

PHP Error Message

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/a5510829/public_html/mailing_list/core/init.inc.php on line 5
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

I know that 000webhost has separate MySQL servers, they tell you what the address is.
For example; mysql4.000webhost.com

But they do tell you what the address is in the MySQL DB section of their control panel.

Now, I haven't done alot of research on them, but there's always a free place called x10hosting.com
I say them because that's the free version of x10premium.com , which I use.

If your not sure, then buy an SSL certificate on the free service ($10 USD annually) and ask if they will check the limits.
(They trust you a lot when youn buy an SSL certificate from them)
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

thanks for your answer :) mine was msql6...... hehe
got connected but it doesn't seem to be saving anything. I have to review the code :S

I could just try to send them an email explaining that right?
do you know if the host you mentioned blocks your account if you don't have the SSL certificate?
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

I have the premium version of x10, so I basically have free reign over whatever I do :3

But x10 basic are still very lenient. I'm pretty sure they offer cPanel, with a built-in mailing list anyway.

You don't have to buy an SSL certificate, but if you don't buy anything and you want to send unlimited amount of emails… they may think that something is up. :P

The reason why I suggested that you buy an SSL certificate is because its the cheapest thing you can buy from their service.
I have a certificate because a lot of personal information goes through my website.

I know that if you contact them asking about their restrictions, and give them a bit of background as to what you are doing, I'm sure that they will work something out.

If you are planning on getting a lot of traffic to your website, you may want to consider paid hosting anyway.
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

Thanks

I'm not getting this

the mysql_error function is giving me this
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' ('firstname', 'lastname', 'email') VALUES ('name', 'john', 'doe' at line 1
its basically saying that the names do not match?

@abcdea
We have disabled registrations from your country of origin due to continued abuse.


ahahahahha
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

May I ask what country you are from ?

Anyway, if you could post your SQL statement, I'll see if I can be of help.
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

this is my add_user function
//adds the given information to the table!
function add_user($firstname, $lastname, $email){
    $firstname = mysql_real_escape_string($firstname);
    $lastname = mysql_real_escape_string($lastname);
    $email = mysql_real_escape_string($email);

    $result = mysql_query("INSERT INTO 'users' ('firstname', 'lastname', 'email') VALUES ('{$firstname}', '{$lastname}', '{$email}')");

    //check for mysql errors
    echo mysql_error();

    return($result !== false) ? true : false;
}
hmm I'm from Portugal :)
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

Ah, problem with your SQL statement.

As far as I know, you don't need to put quotes around the table name, unless it would be something that would look like SQL syntax (eg two dashes) but in which case you would use back tics (`)

Ahhhh, Portugal :)
I went on a study tour there once, beautiful country. However there are lots of spam reports from there :( it's a shame you can't use x10hosting, they really are a great service. I think you may have to ponder ways to use 000webhost efficiently. Maybe contact them about it, they would know more about their service than I :P
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

Where did you study? I'm currently studying in the University of Coimbra :)

I changed the 'users' to `users` and the error message changed saying No Database selected lol
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

Use mysql_select_db();
In the brackets use the same as ur username, in single quotes. (Put it directly after where you connect)

And I studied at Lisbon, law and science. I was only there for 2 weeks :3
(Don't know why)
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

I changed the msql_select_db but not its back up again.

now its giving me another error
Unknown column 'name' in 'field list' ­
I DON´'T EVEN HAVE A NAME FIELD IN THE DB.....

this is very annoying :S

EDIT1: I did it. Its sorted out now.
this way
$result = mysql_query("INSERT INTO `users` (`firstname`, `lastname`, `email`) VALUES ('{$firstname}', '{$lastname}', '{$email}')");
I've changed ' to ` in some places until it finally worked out :)
thanks for your help people
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

Could you do this:

mysql_select_db('db name') or die(mysql_error());
Tell me of it spits out any errors.

And if you could re-paste your user add function.
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

Its already posted in my previous comment.
I found another error because i forgot to specify that the user_id was supposed to auto-increment and forgot the add that :) already done :)
Last edited by Fidbeck on Sun Sep 30, 2012 12:46 pm, edited 1 time in total.
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

Soooooo, fixed?
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

My english sometimes gets messy lol
What I meant is that everything seems to be working pretty fine.

I still have some things to do such as
- making the unsubscribe a proper link (you click and it does what is meant to do, You don't need to copy it and open in another tab)
- find a way to, how can I explain it...
to make a field remember what was written in case of error we have to do this
value="<? echo $contact_name ?>
but even if you successfuly send what was written there, what was written stays there. So it should remember if any error accours and if everything works fine it cleans.
oh and I forgot change it to send as HTML and put some CSS code, but this part I don't know how I should do it.
User avatar
Helx
Posts: 350
Joined: Thu May 17, 2012 6:45 am
Location: Auckland, New Zealand

Re: Jacek's maillinglist tutorial

Post by Helx »

I am so confused...


So, you want a link in the email to unsubscribe, yes?\\

When you send the mail, just put in a link to a page with a $_GET variable on it (I would suggest using base64_encode(); on the email), then read the variable and null all the fields.

Eg http://yoursite.com/unsubscribe.php?email=BASE64'd_EMAIL_HERE

Then just strip the slashes etc, and use sql update.

Most email clients will automatically change URLs to hyperlinks.
Fidbeck
Posts: 147
Joined: Tue Sep 25, 2012 11:40 pm

Re: Jacek's maillinglist tutorial

Post by Fidbeck »

what I meant was to add the <a href> tags to convert the full link into a simple text saying something like Unsubscribe
Post Reply