Jump to content

eciym

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

eciym's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thankyou very, very much Keith you have saved me from a monster migrane!
  2. MySQL 5.0.27 hej, I was wondering if some of you wonderful people could give me a heads up on this, I have been reading up and have summised that I need a LEFT JOIN As i want it to list all the teams regardless of if they have points or not. I have a table of teams with a UID and the team name. then i have a table called points that stores the UID of the teams table as a foreign key, the number of points and each entry is timestamped for historical review later on. what I want to do is display all the teams and the total number of points each team has acrued. I get the sum of the teams with this $query = "SELECT pointsfid, SUM(teampoints) FROM points GROUP BY pointsfid"; I presumed that being a relational database i wouldnt have to save the team name in the points table. Assumed it would be possible to get the team names also. but how to get a query to display the team as well has foxed me. I got this far SELECT pointsfid, SUM(teampoints) AS totalpoints FROM points GROUP BY pointsfid LEFT JOIN teams ON points.pointsfid = teams.teid was I even close? miles out? what did I miss? This seems like it should be so simple. Am I barking up the wrong tree? should I be looking to create a totals feild in the teams table and update that with a total from the points table. to me that seems like it shouldnt be needed. another question pops in to my head also; How do I echo the alias totalpoints in PHP? Thanks in advance for any help with this.
  3. OK I changed the script like you said, however it doesnt give an error message, just runs like it did the update, but doesnt change the database. Another problem i had was an error messsage about headers that somebody here suggested using start_ob() to fix *(there are no spaces on the scripts that usually cause this error). perhaps that has got something to do with it? error message reads Warning: Cannot modify header information - headers already sent by (output started at ptf/member_class.php:132) in ptf/member_class.php on line 92. But perhaps that is a red herring 90 function update_cookie($token) { 91 $cookie = serialize(array($_SESSION['username'],$token)); 92 setcookie('remember',$cookie, time()+12099600); } 131 $ip = mysql_escape_string($_SERVER['REMOTE_ADDR']); 132 print "check session /_$id /_$token /_$session /_$ip /_ $cookie /_ $username /_"; 133 $result = mysql_query("SELECT * FROM member WHERE id='{$id}' AND token='{$token}' AND session='{$session}' AND ip='{$ip}'") or DIE ($this->query_error5); 134if ($result != false){
  4. hmm. i changed it, but it still doesnt update, any other ideas?
  5. Hi, I have this update query and it looks fine to me, however it doesn't update. Could somebody please explain why it doesnt update? It prints out all the variables, it's suposed to. Thanks function byttpass($password) { $db = mysql_connect("localhost","user", "password") or die(mysql_error()); mysql_select_db("db",$db) or die(mysql_error()); echo "+++++ $db +++++"; $id = mysql_escape_string($id); $password = mysql_escape_string(md5($password)); /*echo "$id"; echo "$password"; $result = mysql_fetch_array(mysql_query("SELECT id, username, password, token, session, ip FROM member WHERE id = '{$id}'"), MYSQL_ASSOC); echo "----- $result ------";*/ $update = mysql_query("UPDATE member SET password='$password' WHERE id = '{$id}'") or DIE ($this->query_error); $result = mysql_query($update); $this->message .= '<p>lösenord uppdaterade</p>'; $_POST = "updated"; $this->set_session($result,true); //log user on return true; }
  6. eciym

    php:37??

    Hi, i am getting this error message, however there are no spaces at the beginning or the end of my pages. What other reasons can there be for such a message? I am most interested to know what this part of the error message means ".php:37" Warning: Cannot modify header information - headers already sent by (output started at /home/jasmin/domains/talaatthai.se/public_html/member_class.php:37) in /home/jasmin/domains/talaatthai.se/public_html/member_class.php on line 99 Thanks
  7. Ok after a lot more looking , still dont get the problem, the fuction will not connect with the database and gives the error message, mysql_connect i have even put the connection strings in the function but that hasnt helped. it echos all the variables and fails on INSERT. please if anybody has any idea why it's not working I would appreciate it. function byttpass($password) { $db = mysql_connect("localhost","user", "password") or die(mysql_error()); mysql_select_db("db",$db) or die(mysql_error()); echo "+++++ $db +++++"; $id = mysql_escape_string($id); $password = mysql_escape_string(md5($password)); echo "$id"; echo "$password"; $result=mysql_fetch_array(mysql_query("SELECT id, username, password, token, session, ip FROM member WHERE id = '{$id}'"), MYSQL_ASSOC); echo "$result"; $insert = mysql_query("INSERT INTO member VALUES ('', '', '$password', '', '', '')") or DIE ($this->query_error); $result = mysql_fetch_array(mysql_query("SELECT * FROM member WHERE id = '{$id}' AND password = '{$password}'"), MYSQL_ASSOC) or DIE ($this->query_error1); $this->message .= '<p>lösenord uppdaterade</p>'; $_POST = "UPPDATED"; $this->set_session($result,$remember,true); //log user on return true;
  8. Hi I meekly ask for your help , I have been pawing away at this for a day now and can't get my head around it. it is supposed to change the value of the password for the current user. however upon clicking the submit button, it jumps back to the opening page/begging of the script without changing the password. First off i should say the code was converted from another function that registered new users, so if something looks wrong/idiotic/insane/ill contemplated, it is. I have tried to pluck out what I believe are the important bits. This has been like running around in the dark in a barbed wire factory. form page if($_POST['form_byttpass']) { print ' <h1>Ändra Lösenordet</H1> <form name="form1" method="post" action=""> <table border="0"> <tr> </tr> <tr> <td colspan="2"> <input type="hidden" name="register" value="true"> <input type="" name="id" value="'.$id.'"></td> <td>password:</td><td><input type="password" name="password" value=""></td> </tr> <tr> <td colspan="2" height="20px" valign="bottom" align="right"><input type="submit" name="Bytt" value="Ändra"></td> </tr> </table> </form>'; included as a file in form page. function byttpass($password) { $username = mysql_escape_string($id); $password = mysql_escape_string(md5($password)); $result=mysql_fetch_array(mysql_query("SELECT * FROM member WHERE id = '{$id}'"), MYSQL_ASSOC); $insert = mysql_query("INSERT INTO member VALUES ('', '', '$password', '', '', '')") or DIE ($this->query_error); $result = mysql_fetch_array(mysql_query("SELECT * FROM member WHERE id = '{$id}' AND password = '{$password}'"), MYSQL_ASSOC) or DIE ($this->query_error1); $this->message .= '<p>lösenord uppdaterade</p>'; $this->set_session($result,$remember,true); //log user on return true; } else { $this->message .= 'somfins gone broken'; return false; }
  9. thank you. now i can stop aggravating my forming stomach ulcer. looks like i have a lot of learning to do.
  10. Hi I have this very simple form, and want it to insert some data in to some field. Very simple you might think however after following the step by step functions a gazillion times it still doesn't work. I get no error message, it prints the variables before the insert query and prints the text "Records added to the database" after it is supposed to be inserted. But the table remain empty... it's beaten me and now I implore the help of somebody who knows what they are doing. <?php mysql_connect("localhost", "usr", "pwd") or die(mysql_error()); mysql_select_db("dbname") or die(mysql_error()); ?> ... <?php print $erbjmarke; print $erbjartikel ; print $erbjxpris ; print $erbjordpris ; $query = "INSERT INTO erbjudan (erbjmarke, erbjartikel, erbjxpris, erbjordpris) VALUES ('$erbjmarke','$erbjartikel','$erbjxpris','$erbjordpris')"; print "Records added to the database"; ?> Thank you in anticipation
×
×
  • 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.