Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    mysql_fetch_array trouble please help!

    ok heres what I need help with, please and thankyou.

    everything works rather well only one problem. the output for $oto_html echos: nothing

    by messing with the [$count] and moving some things arround I have got the words: e, array, align="center">
    none at the same time of course. everything works like it should except the output of $oto_html any ideas?

    Thank You in advance

    WordPress Page--------------------------------------------------------
    <?php

    $hostname = "localhost";
    $username = "uname";
    $password = "pword";
    $usertable = "dbtable";
    $dbName = "database";
    MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
    @mysql_select_db( "$dbName") or die( "Unable to select database");

    global $current_user;
    $current_user = wp_get_current_user();

    $query = mysql_query("SELECT * FROM dbtable WHERE user='$current_user->ID'");

    $count=0;
    while($row = mysql_fetch_array($query))

    {
    $count++;
    $otoname[$count]= $row['oto_name'];
    $otohtml[$count]= $row['oto_html'];
    }

    ?>

    <form method="post" action="myoto.php"/>
    <select name="oto" size="<?php echo $count?>">
    <?php for ( $counter = 1; $counter <= $count; $counter++)
    {
    ?>
    <option value="<?php echo $otoname[$counter] . "\">" . $otoname[$counter]?></option>
    <?php } ?>
    </select>
    <input name="otohtml" type="hidden" value="<?php echo $otohtml[$counter] ?>"/>
    <input name="Submit" type="submit" " value="Select My OTO">
    </form>


    myoto.php------------------------------------------------------------
    just parts that deal with the php shown
    <?php

    $oto=$_POST['oto'];
    $oto_html=stripslashes($_POST['otohtml']);

    ?>
    <div align="center">
    <div style="width:799px;">

    <div style="background:url('images/Header1.jpg'); height:244px; width:799px; margin-top:3px;"></div>

    <div style="background:url('images/border2.jpg');">
    <form action="" id="oto" name="oto" width=799 method="POST">
    <div align="center">
    <label></label>
    <table width="550" height="72" border="2">
    <tr>
    <td width="164" height="28"><strong>My OTO Title:</strong> </td>
    <td width="376"><label>
    <input type="text" size="52" maxlength="100" VALUE="<?=$oto;?>">
    </label></td>
    </tr>
    <tr> <a href="members">Return To Your Members Page</a> </tr>
    </table>
    <h3>My OTO Html Code </h3>
    <div height:244px; width:799px;>
    <textarea name="oto_html" cols="80" rows="30"><? echo $oto_html; ?></textarea>
    </div>
    </p>
    <table width="200" border="0">
    <tr>
    <td><div align="center">
    <label>
    </label>
    </div></td>
    </tr>
    </table>
    </div>
    <input type="hidden" name="MM_insert" value="oto">
    </form>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    everything works like it should except the output of $oto_html any ideas?
    How did you confirm that? have you added any error checks to your query/code?
    $query = mysql_query("SELECT * FROM dbtable WHERE user='$current_user->ID'");
    Change the above to
    PHP Code:
    echo $sql="SELECT * FROM dbtable WHERE user='$current_user->ID'";
    $query mysql_query($sql) or die(mysql_error()); 
    and check the output.

    PS: Don't wrap the integer variables with single quotes, inside queries.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •