Hello and welcome to our community! Is this your first visit?
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
    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--------------------------------------------------------

    $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'");

    while($row = mysql_fetch_array($query))

    $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 } ?>
    <input name="otohtml" type="hidden" value="<?php echo $otohtml[$counter] ?>"/>
    <input name="Submit" type="submit" " value="Select My OTO">

    just parts that deal with the php shown


    <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">
    <table width="550" height="72" border="2">
    <td width="164" height="28"><strong>My OTO Title:</strong> </td>
    <td width="376"><label>
    <input type="text" size="52" maxlength="100" VALUE="<?=$oto;?>">
    <tr> <a href="members">Return To Your Members Page</a> </tr>
    <h3>My OTO Html Code </h3>
    <div height:244px; width:799px;>
    <textarea name="oto_html" cols="80" rows="30"><? echo $oto_html; ?></textarea>
    <table width="200" border="0">
    <td><div align="center">
    <input type="hidden" name="MM_insert" value="oto">

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Thanked 2,224 Times in 2,211 Posts
    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