PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$sql = "SELECT * FROM $table_name
WHERE email = "$email" AND username = "$username" AND password = password("$password")
";
?>
Can I have this kind of command in that format. I have a sign up script and then it ask for your email. When I add email in this script it doesn't let me login. That is not the whole script though. But when I login into the site then it says invalid login. When I get rid of email=\"$email\" then it works. I can't figure out how to take the information from email to define it to $email and then put it in the post so they are in 2 different tables in mysql so people can view there in email in post that they post. It also adds it into the cookie to keep it defined but I can't get it to define it before the cookie.
If this seems confusing ask me the questions you need to.
No, they do not type it in when they login. I was trying to get it so that when they are logged in then it loads there email into a varible so then when the news thing says posted by $user then you can click it so when you click $user then it will email them. I know hwo to do that it just isn't opening the email up into a varible.
<?php
$sql = "SELECT * FROM $table_name
WHERE email = "" AND username = "$username" AND password = password("$password")
";
?>
which will find all results where username=$username AND password=password("$password") AND email="" (no email set). Also, you said that the email is in a second table? if thats the case, you'd need to add that table to the select query, but maybe I just misunderstood you.
ok, I understand that now. ok, I have 2 tables in MySQL. news_news and news_users. news_isers has the email stored in it. I want to open it and make it defined so when they post a article then it shows there email in the post. But it doesn';t have anything to add to the email tables in news_news
will include all records that have the value 1 in the field id and will return only the column fieldA. So there WHERE-clause is only to select certain records, not certain columns
Since these are the very basics of SQL I suggest you read one or two tutorials for beginners before going on - it'll help
I put this in here to select the email that is in there and now I did try to put it in $results but that did not work. Gave me errors. I want to make it load email to the cookie so it will work right with my script.
$sql = "SELECT * FROM $table_name
WHERE username = "$username" AND password = password("$password")";
what you are doing is getting all fields from the table $table_name that match the supplied username, and password. if you want to get the email of that user you would do something like
Now this is being a pain. When I add $cookie_name_email and $cookie_value_email into the setcookie then I get an error but when I take it out it it all works but I want to put the email into the cookie so it can be placed into the post.
Warning: Wrong parameter count for setcookie() in login.php on line 45
That site just tells you the normal setcookie like I had when I get rid of the email cookie. It doesn't tell you nothing about setting more values and names to it.
First of all, always use mysql_num_rows() because mysql_numrows() is depriciated. Second, you cannot use mysql_num_rows() after you use mysql_fetch_*() you must do it before that. So in turn, try this
Now, when I ,put that in it works, but now it still doesn't want to add email into the varible stil because it will not add email to the table in news_news