View Full Version : mysql_fetch_array trouble please help!

06-27-2010, 09:08 PM
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">

06-28-2010, 08:22 AM
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

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.