Jump to content

mattm1712

Members
  • Posts

    108
  • Joined

  • Last visited

Posts posted by mattm1712

  1.  

    this is my script,

     

     

    <?php

    include 'connect.inc';

    $result4 = mysql_query("SELECT * FROM comments JOIN users on comments.submittedby=users.name WHERE comments.id=$t");

        while($row = mysql_fetch_assoc($result4));

      {

        $to      = $row['email'];

    $subject = 'the subject';

    $message = 'hello';

    $headers = 'From: webmaster@example.com' . "\r\n" .

        'Reply-To: webmaster@example.com' . "\r\n" .

        'X-Mailer: PHP/' . phpversion();

     

    mail($to, $subject, $message, $headers);

      }

    ?>

     

     

    and my tables are

     

    users

    ------------------------------------------------------

    name  |    email    |    pass    |    location

     

    and

     

    comments

    ------------------------------------------------------

    submittedby  |  title      |    id    |  comment

     

    i cant see y its wrong

     

  2. hi i sort of under stand but it doesnt seem to work

     

    i have changed it to

     

    SELECT * FROM comments JOIN users on comments.submittedby=users.nameWHERE comments.id=$t

     

    my tables are

    users

    ------------------------------------------------------

    name  |    email    |    pass    |    location

     

    and

     

    comments

    ------------------------------------------------------

    submittedby  |  title      |    id    |  comment

     

    i cant see y its wrong

     

     

  3. i have been given this code which is wrong because it doent match my databases

    but i have never seen this join function before

     

    <?php

     

    $result4 = mysql_query("SELECT * FROM comments JOIN users on comments.submittedby=users.name WHERE comments.id=$t");

        while($row = mysql_fetch_assoc($result4));

      {

        $to      = $row['email'];

    $subject = 'the subject';

    $message = 'hello';

    $headers = 'From: webmaster@example.com' . "\r\n" .

        'Reply-To: webmaster@example.com' . "\r\n" .

        'X-Mailer: PHP/' . phpversion();

     

    mail($to, $subject, $message, $headers);

      }

    ?>

     

     

     

    in my database i have 2 tables one called 'users' which has titles.    name email and pass  then i have another one called comments  with titles  id comments submittedby and title. 

     

    i have the varible t$ which will be equal to the id in the comments table, from this i want to selct the submittedby name in the commens table, this wi be the same as the name in the users table, then i want to echo out the email adress.

     

    can anyone help?

  4.  

    $t is difeined in my index page

     

     

    <?php

     

    $result4 = mysql_query("SELECT * FROM comments WHERE id=$t");

    if($result4) {

        $row = mysql_fetch_assoc($result4);

        $name = $row['submittedby'];

    $query4 = mysql_query("SELECT * FROM user WHERE $name=name");

    $row2 = mysql_fetch_assoc($query4);

    $email = $row2['email'];

    }

     

     

    $to      = '$email';

    $subject = 'the subject';

    $message = 'hello';

    $headers = 'From: webmaster@example.com' . "\r\n" .

        'Reply-To: webmaster@example.com' . "\r\n" .

        'X-Mailer: PHP/' . phpversion();

     

    mail($to, $subject, $message, $headers);

    ?>

     

  5. im new to php so if this is a stupid question just say so

     

    i have made a comment system where it just posts commentes into a data base with, my data being username, email , comment and a idnumber

     

    say i have a varible $t  is  post number 120 and a want to get the username from the data base how would i do that?

     

    matt

  6. hi i have the code

     

    $date = date("d-M-Y",$array['date']);

     

    i am echoing out the date correctly but i want to echo the time aswel but not sure how i have tried

     

    $date = date("d-M-Y",time(),$array['date']);

    but no luck can any1 help?

     

     

    cheers matt

  7. i need a code that posts the latest 10 title in the database

    i have this but i know its wrong

     

     

    <?php

     

    include 'connect.inc';

    echo "recent posts";

    $recent = mysql_query("SELECT * FROM comments ORDER BY date DESC LIMIT 10");

    $array = mysql_fetch_assoc($recent);

    $post_title = $array['tilte'];

    while($array = mysql_fetch_assoc($recent))

    {

    echo "$post_tilte";

     

     

    }

    ?>

     

     

  8. hi im  pretty new to php have been teaching myself, i have come to a problem

    i have an index page where i have 4 variables 1 2 3 4 each with include pages in so i click a link in my menu and it changes the body page to 1 of the 4 variables, but now i want to create a page with varibale in.

     

    so i say i click a link on my index page its goes to  index.php?variable=2    but on that page i want titles where u click them and it loads a page within that page.

     

    does any1 understand? lol

    please help

     

    matt

  9. hi i try using this code but i get this error

     

    Parse error: syntax error, unexpected $end in /home/sites/moseleyengineering.co.uk/public_html/matt/newpass.php  on line 45

     

    normally when i get errors like this i have missed brackets out but your code looks fine

  10.  

    can any1 help me this script just guves me a blank scrren i had it working then i add the bit where it tells the user there password has changed now it doesnt work  plz help

     

     

    <?php

     

    session_start();

     

    $user = $_SESSION['user'];

     

    If ($user)

     

    if ($_POST['submit'])

    {

     

    $oldpassword = md5($_POST['oldpassword']);

    $newpassword = md5($_POST['newpassword']);

    $repeatnewpassword = md5($_POST['repeatnewpassword']);

     

    echo "$oldpassword/$newpassword/$repeatnewpassword";

     

    include 'connect.inc';

     

    $queryget = mysql_query("SELECT pass FROM users WHERE name='$user'");

    $row = mysql_fetch_assoc($queryget);

    echo $oldpassworddb."<br>";

    echo $oldpassword."<br>";

     

    $oldpassworddb =$row['password'];

     

     

    if ($oldpassword==$oldpassworddb)

    {

    if ($newpassword==$repeatnewpassword)

    {

    echo "pass changed";

    }

    else

    die("pass dont  match!");

     

    }

    else

    {

     

    echo"

     

    <form action='newpass.php' method='POST'>

    Old password: <input type='text' name='oldpassword'><br>

    New password: <input type='password' name='newpassword'><br>

    Repeat password: <input type='password' name='repeatnewpassword'><br>

    <input type='submit' name='submit' value='change password'>

    </form>

    ";

    }

    }

    ?>

  11. this is the error im getting

     

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sites/moseleyengineering.co.uk/public_html/matt/delete.inc  on line 28

     

    which is

     

    $sql = "DELETE FROM comments WHERE id=$_GET['id']";

  12. hi this script deosnt work i cantunderstand y?

     

    these are the 3 coloums in my database

     

    id

    comments

    submittedby

     

    this is the code

    <?php

     

    $dbusername="web123-matt";

    $dbpassword="matt";

    $dbdatabase="web123-matt";

    mysql_connect(localhost,$dbusername,$dbpassword);

    mysql_select_db("comments");

     

    if(!isset($_GET['cmd']))

    {

        $result = mysql_query("select id, comments, submittedby FROM comments ORDER BY id");

     

        while($r = mysql_fetch_assoc($result))

        {

            $id = $r['id'];

            $comments = $r['comments'];

            $submittedby = $r['submittedby'];

         

            echo "<a href='delete.php?cmd=delete&id=$id'>$submittedby - Delete</a>";

          echo "<br>";

        }

    }

    elseif(isset($_GET['cmd']))

    {

      if($_GET["cmd"]=="delete" && (isset($_GET['id']) && is_numeric($_GET['id'])))

        {

            include 'connect.inc';

            $sql = "DELETE FROM comments WHERE id=$id";

            $result = mysql_query($sql);

            echo "Row deleted!";

        }

     

    }

     

    ?>

  13. yeah i have i have 

     

    id

    comments

    submittedby

     

    this is the code

    <?php

     

    $dbusername="web123-matt";

    $dbpassword="matt";

    $dbdatabase="web123-matt";

    mysql_connect(localhost,$dbusername,$dbpassword);

    mysql_select_db("comments");

     

    if(!isset($_GET['cmd']))

    {

        $result = mysql_query("select id, comments, submittedby FROM comments ORDER BY id");

       

        while($r = mysql_fetch_assoc($result))

        {

            $id = $r['id'];

            $comments = $r['comments'];

            $submittedby = $r['submittedby'];

           

            echo "<a href='delete.php?cmd=delete&id=$id'>$submittedby - Delete</a>";

          echo "<br>";

        }

    }

    elseif(isset($_GET['cmd']))

    {

      if($_GET["cmd"]=="delete" && (isset($_GET['id']) && is_numeric($_GET['id'])))

        {

            include 'connect.inc';

            $sql = "DELETE FROM comments WHERE id=$id";

            $result = mysql_query($sql);

            echo "Row deleted!";

        }

     

    }

     

    ?>

     

     

     

    but its works fine but when i go back to the comments its still there and hasnt been deleted

     

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