PHP Problem - Help needed menu

Shout-Out

User Tag List

Results 1 to 4 of 4
  1. #1
    Falgern's Avatar Member
    Reputation
    6
    Join Date
    Mar 2007
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Problem - Help needed

    Hello
    I've got a bit of PHP problem.
    I'm trying to make a page that updates a row in a database. and another page reads from that row and gets its text from it.. some kind of easy posting/updating system.
    But i've run into some really big problem.

    Code:
    <?php 
    $submit = $_POST['submit']; 
    $text = $_POST['text']; 
    
    $db = mysql_connect(localhost, ******, *****); 
    mysql_select_db(******); 
    
    if ($submit) { 
    $result = mysql_query("UPDATE pages SET lol = $_POST[text] WHERE id = '1'" ); 
    
    
    } else{ 
    ?> 
    <form action="indexupdate.php" method="post"> 
    Text <input type="text" name="text" size="30" style="width: 300px; height: 100px;"> 
    
    
    <p><INPUT TYPE="Submit" name="submit" value="Change"> 
    
    <?php 
    $submit = $_POST['submit']; 
    $lname = $_POST['text']; 
    } // end if 
    ?>

    Thats the code i've done so far. but it doesnt work, i cant however see anything wrong in it.

    also, is there an easy way to make a page to read from database?


    Thank you.

    PHP Problem - Help needed
  2. #2
    Le Froid's Avatar Contributor
    Reputation
    172
    Join Date
    Mar 2007
    Posts
    1,327
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $ = mysql_query("UPDATE pages SET lol =  $ WHERE id = '1'" );
    remove the result maby? if nothing is using "$result" it is not needed. See if it works

  3. #3
    XTZGZoReX's Avatar Active Member
    Reputation
    32
    Join Date
    Apr 2008
    Posts
    173
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, I doubt you can start an If-statement in one PHP enclosed block of code, and end it in another.. Besides, doing it the normal way is more efficient.

  4. #4
    siliconslayer's Avatar Member
    Reputation
    1
    Join Date
    May 2008
    Posts
    3
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont think you can put variables straight into a mysql quey like that

    i tend to append it into another variabe first

    $query = "UPDATE pages SET lol = ".$_POST['text']." WHERE id = '1'";
    $result = mysql_query($query);

    * not sure if you need lol = '".$_POST['text']."' <-- i added (') single quotations try both

    i suggest you read about sql injection also

    To read form a database do

    $db = "database name here";
    $query = "SELECT * FROM".$db." WHERE lol = '$lol' ORDER BY lol DESC"; // <---adjust the where and order by statements as desired.

    $result = mysql_query($query);
    while ($output = mysql_fetch_assoc($result)) //<-- you can use mysql_fetch_array() here instead
    {
    echo $output['lol'];
    }

Similar Threads

  1. [Trinity] Help Needed - Custom Trainer problem...
    By Taligaro in forum WoW EMU Questions & Requests
    Replies: 5
    Last Post: 06-08-2012, 06:00 AM
  2. [HTML][PHP] Table width, newssystem - Help needed!
    By Harambeqt in forum Programming
    Replies: 9
    Last Post: 06-05-2012, 10:30 AM
  3. [HELP!!!!] Need help with small problem.!!!!
    By Jayson22 in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 05-18-2008, 05:55 AM
  4. Recovery problems, help really needed!
    By stradivuckos in forum Community Chat
    Replies: 4
    Last Post: 08-08-2007, 07:41 AM
  5. Big ass problem and needing help.
    By kalish in forum WoW ME Questions and Requests
    Replies: 3
    Last Post: 12-14-2006, 08:32 PM
All times are GMT -5. The time now is 04:44 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search