[PHP-DB] Re: mysql_fetch_array
Maybe on the 14th record the while statement is false. Try do...while ??? Jochem F.Collineau wrote: Hi, Here is my code: ? require(util.php); $sql= new MySQL_class; $sql-Setup(user,user,localhost); $sql-connexion(materiel); $sql-Query(select nom from personne); $cpt=0; while($row=mysql_fetch_array($sql-result)) { print($cpt); print(br); print($row[nom]); print(br); $cpt++; } $sql-close; ? The personne table has 14 articles. but with this code i can see only 13 articles here is the output on a browser: 0BRUYÈRE 1COLLINEAU 2ELIAS 3GLOANEC 4HUGOT 5LE BRIS 6LE FLOCH 7LEMAUVIEL 8LOUVEL 9MARTINIERE 10OGUET 11THOMAS 12VASSELET What is the problem ? Thanks Franck -- Faites un voeu et puis Voila ! www.voila.fr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_fetch_array() question
Hi everyone, I think I've got the problem sorted, I'll soon let y'all know if it doesn't work ! Cheers, Graeme :) On Mon, 2002-11-04 at 21:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_fetch_array pointer
mysql_data_seek($result_cat,0); http://www.php.net/manual/en/function.mysql-data-seek.php On Tue, 29 Aug 2000 22:55:11 +1200, Jeffrey Barendse wrote: I like to use a script like this: $result_cat = mysql_query(select cat_naam from categorie order by cat_naam); while($row = mysql_fetch_array($result_cat)) { echo 'OPTION VALUE=' . (urlencode($row[cat_naam])) . '' . $row[cat_naam]; } while($row = mysql_fetch_array($result_cat)) { echo $row[cat_naam]; } In the first while function it works fine. But in the other I have no date. I suppose the mysql_fetch_array sets a pointer. Is there a way to reset the pointer so I can reuse a query? Regards, Jeffrey Barendse WireITup -- Jason Morehouse ([EMAIL PROTECTED]) Netconcepts LTD - Auckland, New Zealand * Linux: Because rebooting is for adding hardware. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: mysql_fetch_array() doesn't work
Hello, First, Thank you all for your help! I finally found the reason for why does the IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line] It is because the echo (including print) doesn't work at the line below, echo trtda href=\profile.php?id=$arr['user_id']\ target='_top'; showing the error info as I mentioned. ( but it should work according to PHP books) It only works when the $arr['user_id'] is out of the quotes. echo trtda href=\profile.php?id=.$arr['user_id'].\ target='_top'; then IE showed no error any longer. So I have to let all $arr['key'] out of the quotes, then the scripts are Ok. Regards Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: mysql_fetch_array() doesn't work
-Original Message- From: Web user [mailto:[EMAIL PROTECTED]] Sent: 30 September 2001 22:15 To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: mysql_fetch_array() doesn't work [snip] It only works when the $arr['user_id'] is out of the quotes. echo trtda href=\profile.php?id=.$arr['user_id'].\ target='_top'; then IE showed no error any longer. So I have to let all $arr['key'] out of the quotes, then the scripts are Ok. Regards Mike No need for quotes anyway: $arr[key] works just fine :) regards -- Jason Wong Gremlins Associates www.gremlins.com.hk Tel: +852-2573-5033 Fax: +852-2573-5851 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: mysql_fetch_array() doesn't work
there doesn't look to be any problem with the code you've shown. it would be helpful, however, if you included the full error including the line and the lines surrounding this point as the error probably lies in previous code. Steve Web User [EMAIL PROTECTED] wrote in message 008501c1459e$5dd87260$6a915fd3@hexiao">news:008501c1459e$5dd87260$6a915fd3@hexiao... System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 ? .. .. $res=mysql_query($query); $num=mysql_num_rows($res); for($i=0; $i$num; $i++){ $arr=mysql_fetch_array($res); ... } ... When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\...\page.php on line ... What's the problem wiht mysql_fetch_array() or other? Thanks! Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: mysql_fetch_array() doesn't work
I agree with Steve. Also, print value of $num; is it 0? Is $res valid; is it NULL? We need far more details than what you think we need. -Original Message- From: Steve Brett [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 25, 2001 6:34 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: mysql_fetch_array() doesn't work there doesn't look to be any problem with the code you've shown. it would be helpful, however, if you included the full error including the line and the lines surrounding this point as the error probably lies in previous code. Steve Web User [EMAIL PROTECTED] wrote in message 008501c1459e$5dd87260$6a915fd3@hexiao">news:008501c1459e$5dd87260$6a915fd3@hexiao... System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 ? .. .. $res=mysql_query($query); $num=mysql_num_rows($res); for($i=0; $i$num; $i++){ $arr=mysql_fetch_array($res); ... } ... When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\...\page.php on line ... What's the problem wiht mysql_fetch_array() or other? Thanks! Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: mysql_fetch_array
try just changing mysql_fetch_array to mysql_fetch_assoc Bryan [EMAIL PROTECTED] wrote in message 006801c1192c$649f6e30$272478cc@bryanspc">news:006801c1192c$649f6e30$272478cc@bryanspc... mysql_fetch_array places 2 records for each one returned (example) Array ( [0] = 56 [location_id] = 56 ) Is there any way to delimate that and have the key present only once? here is my code : /* * * * Start code * * */ while ($aRow = mysql_fetch_array($sResult) ) { print_r($aRow); foreach ($aRow as $key = $sValue) { $sData[$key] = SELECT * FROM location WHERE region='$sValue' AND region !='yes'; $sDataResult[$key] = mysql_query($sData[$key], $sDbcnx) or die(mysql_error()); /* print Main heading linking to no where */ print OPTION VALUE=\#\.$sValue./OPTION; while($aData[$key] = mysql_fetch_array($sDataResult[$key]) ) { /* grab the data from the main heading and print all the info for that record */ print OPTIONVALUE=\indexes/index.php?iLoc_id=.trim($aData[$key]['location_ id']).\nbsp;nbsp;nbsp;.trim($aData[$key]['location'])./OPTION\ n; } /* end while */ } /* end foreach */ } /* end main while */ /* * * * End Code * * */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Re: mysql_fetch_array problem
What's your code look like, something like this? $result = mysql_query(SELECT name FROM tablename); while ($row = mysql_fetch_array($result)) { print Name : . $row['name'] . br\n; } The above is the most standard way at least. Share your appropriate snippet of code, could be a few reasons. Regards, Philip Briansander wrote: Greetings, I'm experiencing the strangest problem and I was wondering if anyone else has had the same problem. I have a fairly simple script setup that queries a mySQL database and displays the records in a HTML table. Everything works fine except it keeps omitting the first record. Running the query directly on the database returns 3 records but only 2 are displayed in the table. I just upgraded to PHP 4.0.6 and I'm still having the problem. I've also tried using mysql_fetch_array and mysql_fetch_object, both produce the same results. The first record is left out every time. Any idea as to what the problem might be? Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]