twittoris Posted September 7, 2010 Share Posted September 7, 2010 I am retrieving a rowfrom a table and when I post the row variable it doesnt read it. ___ $query = "SELECT * FROM $tbl_name"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['name']; echo "<br />"; $postinfo = 'p_doctor_name=' . $row .'&p_name_type=A&p_search_type=BEGINS'; __ This outputs p_entity_name=&p_name_type=A&p_search_type=BEGINS Note that it is missing $row Do I need to put it in an array? Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/ Share on other sites More sharing options...
twittoris Posted September 7, 2010 Author Share Posted September 7, 2010 I had the wrong thing on my clipboard. it out puts p_doctor_name=&p_name_type=A&p_search_type=BEGINS Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108155 Share on other sites More sharing options...
Rifts Posted September 7, 2010 Share Posted September 7, 2010 i think this $postinfo = 'p_doctor_name=' . $row .'&p_name_type=A&p_search_type=BEGINS'; should be $postinfo = 'p_doctor_name=' . $row['name'] .'&p_name_type=A&p_search_type=BEGINS'; Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108167 Share on other sites More sharing options...
twittoris Posted September 7, 2010 Author Share Posted September 7, 2010 no the same thing happens. I think instead of echo i should store the rows in an array but i have never used an array like this before. Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108254 Share on other sites More sharing options...
Rifts Posted September 7, 2010 Share Posted September 7, 2010 what do you get when you just have this code only $query = "SELECT * FROM $tbl_name"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['name']; echo "<br />"; Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108427 Share on other sites More sharing options...
twittoris Posted September 7, 2010 Author Share Posted September 7, 2010 A list of the rows in the table. For some reason it isnt inserting into the string. Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108468 Share on other sites More sharing options...
twittoris Posted September 8, 2010 Author Share Posted September 8, 2010 Fixed it you have to put all the cURL settings in the loop. Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108511 Share on other sites More sharing options...
HaLo2FrEeEk Posted September 8, 2010 Share Posted September 8, 2010 I can think of a few reasons you might be having an issue. If you solved this already then great, but I'd still like to put in my $0.02 (two cents.) First, unless you're just not posting it, I don't see an end to your while loop. You're missing the closing } Next, you're using mysql_fetch_array, which returns a numerically-indexed array, not an associative array, yet you're trying to get the value from the result using $row['name'], you should change mysql_fetch_array() to mysql_fetch_assoc(). And finally, $row is an array, not a string, so when echoing it you're only going to get this: Array() What you should do is something like this: $query = mysql_query("SELECT * FROM $tbl_name") or die(mysql_error()); while($row = mysql_fetch_assoc($query)) { echo = "p_doctor_name=" . $row['name'] . "&p_name_type=A&p_search_type=BEGINS"; echo "<br>\n"; } This will print the POST info that you want. Alternatively, if you want to use the POST info later in the script, you could change the first echo line in the loop, to this: $postinfo[] = "p_doctor_name=" . $row['name'] . "&p_name_type=A&p_search_type=BEGINS"; And remove the echo "<br>\n"; line. That will create an array containing each of the lines, which you can then iterate through in a foreach loop. Quote Link to comment https://forums.phpfreaks.com/topic/212737-sql-table-query-result-not-passing-to-post-string/#findComment-1108563 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.