Jump to content

marcus

Members
  • Posts

    1,842
  • Joined

  • Last visited

Posts posted by marcus

  1. ok, just some mysql updating a row help needed

    [code=php:0]
    if($act == edit)
    {
    $q = "SELECT * FROM `shoutbox` WHERE `id`=$id";
    $query = mysql_query($q);
    $shout = mysql_fetch_array($query);
    echo"
    <table border=0 cellspacing=0 cellpadding=1>
    <tr><td>
    <form action=shoutadmin.php method=post>Name:<td><input type=text name=mname value=$shout[name]>
    <tr><td>
    Website:<td><input type=text name=mwebsite value=$shout[website]>
    <tr><td>
    Message:<td><input type=text name=mmessage value=$shout[message]>
    <input type=hidden name=messid value=$shout[id]>
    <input type=hidden name=action value=doedit>
    <tr><td colspan=2>
    <input type=submit value='Edit'>
    </table>
    ";
    }
    if($act == doedit)
    {
    $mname = $_POST[mname];
    $mwebsite = $_POST[mwebsite];
    $mmessage = $_POST[mmessage];
    $messid = $_POST[messid];
    $sqll = "UPDATE `shoutbox` SET `name` = '$name',
    `website` = '$website',
    `message` = '$message' WHERE `id` =$messid LIMIT 1 ";
    $ress = mysql_query($sqll);
    echo"Shout Edited";
    }
    [/code]

    alright, the first part where it shows everything works, but when i update it, it doesnt work. it just stays the same, any ideas?
  2. i am making a shoutbox, and when i want to echo/print off the rows in the table it keeps printing thousands of commas

    code:

    [code]
    <?php
    include('mysql.php');
    $sql = "SELECT * FROM shoutbox";
    $res1 = mysql_query($sql);
    echo "<tr><td>";
    echo "<div style='border:0px solid black; height:200px; width:130px; overflow:auto; font-family:verdana;font-size:10pt;color:black;'>";
    while("$res2 = mysql_fetch_assoc($res1), MYSQL BOTH"){
    printf ("<a href='$res2[website]'>$res2[name]</a><br>$res2[message]");
    };
    mysql_free_result($res1);
    ?>
    [/code]

    help?
  3. [code]
    mysql_connect("localhost","root","root");
    mysql_select_db("dbname");
    $query = mysql_query("SELECT * FROM tablename");

    $fi = "test.xml";
    echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>
    <rss version=\"2.0\">
    <channel>";
    while ($row1 = mysql_fetch_array($query, MYSQL_BOTH)) {
        echo "&nbsp;";
        printf ("
      <title>Test XML File</title>
      <link>yeah</link>
      <description>yeah</description>
      <item>
      <title>%s</title>
      <link>%s</link>
      <description>Added on %s at %s.</description>
      </item>",$row1[title],$row1[url],$row1[date],$row1[time]);
    };
    mysql_free_result($query);
    echo "</channel>
    </rss>";
    [/code]

    you can try that
  4. [code]
    $sql = "INSERT INTO usesrs (group, user_name, password, first_name, last_name, gender, email_address) VALUES ('2', 'user', 'pass', 'isaac', 'meals', 'male', 'email')";
    $result = mysql_query($sql);
    if($result){
          echo "successful in registering you an account";
    }
    else
    {
          echo "couldn't submit";
          echo "
    ";
          echo $group;
          echo "
    ";
          echo $first_name;
          echo "
    ";
          echo $last_name;
          echo "
    ";
          echo $user_name;
          echo "
    ";
          echo $email_address;
          echo "
    ";
          echo $password;
          echo "
    ";
          echo $gender;
    }
    [/code]
  5. First file:

    [code]
    <?php
    $connection = mysql_connect(localhost,zack_rpg,omfgg212);
    $db = mysql_select_db(zack_rpg,$connection);
    $sql111 = "SELECT * FROM stats WHERE id=$_COOKIE[id]";
    $res454 = mysql_query($sql111);
    $res1 = mysql_fetch_array($result454, MYSQL_BOTH);
    $mana = $res1[mana];
    $level = $res1[level];
    $ladd = $level * 20;

    if($mana < $ladd){
    $sql = "UPDATE stats SET mana = $mana + 2";
    $result = mysql_query($sql);
    }else{
    die();
    };
    ?>
    [/code]

    Second file:

    [code]
    <?php
    $connection = mysql_connect(localhost,zack_rpg,omfgg212);
    $db = mysql_select_db(zack_rpg,$connection);
    $sql111 = "SELECT * FROM stats WHERE id=$_COOKIE[id]";
    $res454 = mysql_query($sql111);
    $res1 = mysql_fetch_array($result454, MYSQL_BOTH);
    $health = $res1[health];
    $level = $res1[level];
    $ladd = $level * 100;

    if($health < $ladd){
    $sql = "UPDATE stats SET health = $health + 10";
    $result = mysql_query($sql);
    }else{
    die();
    }
    ?>
    [/code]

    Errors:
    [code]
    X-Powered-By: PHP/4.4.4
    Content-type: text/html

    <br />
    <b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/zack/public_html/rpg/cron/update_mana.php</b> on line <b>6</b><br />
    [/code]

    [code]
    X-Powered-By: PHP/4.4.4
    Content-type: text/html

    <br />
    <b>Warning</b>:  mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/home/zack/public_html/rpg/cron/update_health.php</b> on line <b>6</b><br />
    [/code]
  6. Ok, I get the normal

    [code]
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/zack/public_html/rpg/inc/addxp.php on line 6
    [/code]

    Code:

    [code]
    <?php
    $connection = mysql_connect(localhost,zack_rpg,passwordhere);
    $db = mysql_select_db(zack_rpg,$connection);
    $sql = "SELECT * stats WHERE stats.id=$_COOKIE[id]";
    $res = mysql_query($sql);
    $res2 = mysql_fetch_assoc($res);
    $xp = $res2[xp];
    $rand = rand(0,10);
    $xpadd = "$xp + $rand";
    $sql2 = "UPDATE stats SET xp = `$xpadd` WHERE stats.id=$_COOKIE[id]";
    $res3 = mysql_query($sql2);
    ?>
    [/code]
  7. form:

    [code]
    <form name=fn action=page.php method=post>
    <table border=0 cellspacing=0 cellpadding=3>
    <tr><td>
    Your Name:<td><input type=text name=name value="<?=$_COOKIE[name]?>">
    <tr><td>
    Next Field:<td><input type=text name=field1 value="<?=$_COOKIE[field1]?>">
    <tr><td colspan=2>
    <input type=submit value="Send">
    </table>
    </form>
    [code]

    then page.php

    [code]
    <?php
    $name = $_POST[name];
    $field1= $_POST[field1];

    setcookie(name,$name);
    setcookie(field1,$field1);

    echo "info set";
    ?>
    [/code]

    then once you go back to the other page (not page.php) it should echo off the information in the text fields[/code][/code]
  8. you could always just do

    on your form make like the date:

    [code]
    $date = date("d/m/y");
    [/code]

    then when grabbing it

    [code]
    $date = $_POST[date]; //getting posted
    [/code]

    then to get each field

    [code]
    $d1 = explode("/",$date);
    //or explode("/",$_POST[date]);
    [/code]

    then:

    [code]
    $day = $d1[1];
    $month = $d1[2];
    $year = $d1[3];
    [/code]
  9. Like to store multiple item ids in like a database table for the users and stuff

    like

    [code]
    $sql = "SELECT items FROM userdb WHERE userdb.id=$_COOKIE[id]";
    $result = mysql_query($sql);
    $result2 = mysql_fetch_assoc($result);
    $items = explode(",",$result2);

    while($row == $items){
    echo $fc_array[array_rand($fc_array)];
    };

    mysql_free_result($result);
    [/code]

    would something like that work?
  10. Ok, what I'm trying to do is, if the file does not exist it will echo off like This file does not exist, or whatever.

    Here is my code:

    [code]
    <?php
     
            $page = $_GET[page];
      $ref1  = $_GET[ref];
      $ref  = $_SERVER[REQUEST_URI];

    include('refs.php');
     
      if($page == false){
      //$number = "7";
      include('news/show_news.php');
      }else
    //if(!file_exists($page)){
    //echo "This page does not exist, sorry :(";
    //}else
      if($page == $page){
      include("inc/$page.inc");
      };


        ?>
    [/code]

    But each time I use that, I go to a page does exist it says it doesn't (when uncommented). How can I fix this?
×
×
  • 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.