Get The Array In Odbc_fetch_row To Emulate As Mysql_fetch_row?
I'm converting the mysql_fetch_row to odbc_fetch_row and I ran into this problem. I noticed that I can't use the foreach() after the odbc_fetch_row but I can with mysql_fetch_row. Upon reading at the php.net, it say.
mysql_fetch_row --> "Get a result row as an enumerated array"
odbc_fetch_row --> "odbc_fetch_row -- Fetch a row"
Also, it seem that I can't use the odbc_fetch_array() either as it's undefined. odbc_fetch_into seem promising but it doesn't use the field name but numeric number.
View Complete Forum Thread with Replies
Related Forum Messages:
Odbc_fetch_row Function
Can anyone check this code and let me know whats wrong? I am using Sybase Sql anywhere as a backend and php 4. $mySql = "Select * from news"; $Result = odbc_exec($myConnection, $mySql); while(odbc_fetch_row($Result)){ echo "<tr>"; for($b = 1; $b <= 3; $b++){ echo "<td align='center'><font face='verdana, helvetica, arial' size=ƈ' color='brown'>odbc_result($Result, $b)</font></td>";}} After I use this I get this output odbc_result(Resource id #2, 1) odbc_result(Resource id #2, 2) odbc_result(Resource id #2, 3) But instead of this I actually want to data thats there in the table "news".
View Replies !
Odbc_fetch_row Error
I am running the following code, the field names in the table are correct. i recived the following error: Warning: odbc_fetch_row(): 3 is not a valid ODBC result resource in C:web ootmemlogin1.php on line 42 PHP Code: <?PHP $conn=odbc_connect('DHST','',''); if (!$conn) Â Â {exit("Connection Failed: " . $conn);} if (!isset($_POST['submit'])) //if they haven't pressed the submit button, then show the form.........
View Replies !
Access Violation @ Odbc_fetch_row - But Why?
I get this error: PHP has encountered an Access Violation at 04C3451C It occurs at the while line, as I get a and b, but not c. I run this a number of times, but the 3 first times it works, at the fourth, which returns 2 rows, results in this error at that point. Why? echo "#a "; if(odbc_num_rows($result)>1) { echo "#b "; while(odbc_fetch_row($result)) { echo "#c "; $itemtosearch1[]=odbc_result($result,1); $itemtosearch2[]=odbc_result($result,2); } }
View Replies !
How To Add (or Emulate) A New Superglobal
This is just for curiosity, but: Lets say I would like to have a new superglobal, in addition to automatically made get, post, cookie and session. I mean, I would (theoretically) want to AVOID doing function () { global $config; .... } and just be able to use $config in functions and classes. Not that it would be the nicest practise though. But let's say for the sake of fun or doing it. Is there a way? Of course you could reset, set and reset again some session variable,
View Replies !
Emulate My Browsers
I use Apache/PHP with Webazlier to view the log files. I get a number of user agents (web browsers?) that visit the website - For example: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1 Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90) Mozilla/2.0 (compatible; T-H-U-N-D-E-R-S-T-O-N-E) Googlebot/2.1 (+http://www.googlebot.com/bot.html) Mozilla/3.0 (compatible; Indy Library) ia_archiver SurveyBot/2.2 KaHT How can I change my http user agent - either via a unix shell script or PHP to give the same results for my search engine/crawler?
View Replies !
How To Emulate Isset() ? (is It Possible?)
Take a look at this code (you can execute it): error_reporting(E_ALL); function byVal( $v) {} function byRef(&$v) {} print '<pre>' byVal ($first['inexistent_index']);// gives a notice var_dump($first);// gives a notice print '<hr />' byRef ($second['inexistent_index']);// does NOT give a notice var_dump($second);// does NOT give a notice print '<hr />' isset($third);// does NOT give a notice var_dump ($third);// gives a notice print '</pre>' In the $first case, using byVal(), I get *two* notices. In the $second case, using byRef(), I get *zero* notice. In the $third case, using isset(), I get *one* notice. This means that: 1) byVal() does NOT define the array and raises a notice (and var_dump() raises another notice). 2) byRef() defines the array and does NOT raise notices (neither var_dump() raises a notice, since $second is defined). 3) isset() does NOT define the array and does NOT raise notices (but var_dump() raises a notice, since $third is NOT defined). As you can see, isset() is weird, and I need to emulate its behaviour. The question is: is it possible to do that in PHP?
View Replies !
Emulate Register_globals On
I'm trying to get a PHP script to function, that was originally written to use 'register_globals = on' My server has 'register_globals = off' So as a temporary measure, to emulate register_globals On, I have pasted the code below into the header of my pages. This script was recommended by: uk.php.net... at... Code:
View Replies !
Emulate Browser
I used "curl" to emulate the browser in php. I am trying to retrieve content from a secure website (for instance https://www.bluetooth.org/) using following php script and using $data to store the retrieved contents. PHP Code: <? $ch = curl_init(); $url = "https://www.bluetooth.org/"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); //curl_setopt($ch, CURLOPT_PORT,443); $data = curl_exec($ch); print "result is * $data "; curl_close($ch); ?>
View Replies !
Emulate Register Globals Off
I would like to know how to emulate register globals = off in my php scripts. The server has it turned on and I can't change that so how do I work around it for my pages?
View Replies !
Mysql_fetch_row
I have a little problem, everything is ok when the code is: <?php $sql = "select * from mytable"; //PROBLEM HERE $result = mysql_query($sql); while($myrow=mysql_fetch_row($result)) { echo"<tr><td>$myrow[1]</td><td>$myrow[2]</td><td>$myrow[3]</td><td>$myrow[4]</td><td>$myrow[5]</td><td>$myrow[6]</td><td>$myrow[7]</td><td>$myrow[8]</td></tr>"; } mysql_free_result($result); ?> But when i replace the $sql with $sql = "select * from mytable ORDER BY date"; //added order by it says: Supplied argument is not a valid MySQL result resource in.. Can't find the problem.
View Replies !
Mysql_fetch_row ++
this is the query that i'm running on my sql db. how do i use php to display results from the row before and after this one. $sql = "SELECT * FROM gallery WHERE id ='$id'"; $result = mysql_query($sql,$db); $row = mysql_fetch_row($result);
View Replies !
Mysql_Fetch_Row For The First Row
I've got a while loop that outputs the last 3 tips in a tipsntricks table, and I'd like to do something only for the first row. You can see there is a image in this while loop called anew.gif, and I only want it to be there for the first row(first pass through the loop). I only want to have to query the database one time, so I'm not interested in a solution with multiple queries (I already have one). I'm just doing this to learn MySQL better, but I'm stuck on this. Here's the code: <?php $thisBlurb = mysql_query("SELECT tipTitle, tipCode, tipNum FROM tipsntricks ORDER BY tipNum DESC LIMIT 3"); $color1 = "#f0e8fe"; $color2 = "#E9F3FB"; while($i = mysql_fetch_row($thisBlurb)) { $row_color = ($i['2'] % 2) ? $color1 : $color2; echo "<div style='width:420px; background-color:$row_color; border-top:dotted #567ACE 4px; padding:10px;'>"; echo "<h3 class='h2like'>";.....................................
View Replies !
Mysql_fetch_row()
I'm running a calendar module for Php-Nuke 7.5. I receive the above mentioned error when I try to Edit or Delete a previous calender entry. It's pointing to a link in a php file, below is the line that is causing the problem. list($counter, $radminarticle, $radminsuper) = mysql_fetch_row($result); I've checked my database and it looks fine. I've also removed the databases and re-added them back. This snippet of code seems to cause the same problem if I try to edit or delete an entry. Posting and viewing are fine.
View Replies !
Mysql_fetch_row() After Mysql_data_seek()
Yesterday, I ran into a problem that seems to stem from an unusual behavior of mysql_fetch_row() and mysql_fetch_assoc(). Specifically, I have a query that selects all of the id's of fields matching certain criteria, and I want to then fetch the complete results of a certain subset of those fields, depending on the current result page and number of records to show per page. The original code looked like this: mysql_data_seek($this->query, ($this->page - 1) * $this->limit); for ($i = 0; $i < $this->limit; $i++) { $result = mysql_fetch_assoc($this->query); // The get() method fetches the complete record $this->results[] = $this->get($result[$this->key]); } Unfortunately, this did not work as expected. This either returned the same row every time, or, if I wrote the loop differently, returned one result and then quit. It appears that after calling mysql_data_seek, mysql_fetch_assoc does not advance the result pointer. However, I couldn't find this documented anywhere. My temporary solution also ran into PHP's apparent lack of a C-style break or Perl-style last statement. Does such a thing exist, or am I correct in having to write something like: for ($i = 0; $i < $this->limit; $i++) { // blah blah blah // Force break out of loop if ($row = mysql_num_rows($this->query) { $i = $this->limit; } }
View Replies !
Mysql_fetch_row --> Error! Help Please!
I am using some example PHP code to build a counter for a page on my webserver. When going to that page, I will see the following error message: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:Program FilesApache GroupApache2htdocs est est.php on line 33 And line33 shows as follows: for ($count = 1; $row = mysql_fetch_row($result); ++$count) What did I do wrong here?
View Replies !
Warning: Mysql_fetch_row
im getting the error Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in... i was using the msqli extension but getting a fatal error of Fatal error: Call to a member function fetch_row() on a non-object in so i changed back the the msql extension and have the current problem. do i need to download the latest connector files?
View Replies !
Mysql_fetch_row Function Disappeared!
I'm not sure this is a php question, but it involves php code, so I'm putting it here. I've been trying to print the results from a select on my local development set up... this is ALL on my own machine in an Apache/PHP/MySql bundle. My Apache server is confined to "localhost." I was having a lot of problems with it, getting only one row of results, getting the same row 37 times and such... then suddenly, I got an error message: Call to undefined function mysql_fetch_row() I got the same message for mysql_fetch_array() These functions had worked not ten minutes before, from the same page (I was just changing the "while" statement to try different ways of printing the result). Is there any php-specific reason that this could happen in the MIDDLE of a testing session? If not, it might be something more ominous... my Apache error log lists a lot of refused clients that don't appear to be me! For example, the last one reads: [Thu Mar 21 15:15:16 2002] [error] [client xx.xx.xxx.xxx] client denied by server configuration: c:/phpdev/www/scripts The ip address that I x'd out is not the same IP address that I see when I view mail headers, or that is listed in my mysqladmin window. What's more, there's a variety of *different* IP numbers in the error logs. I'm on a cable modem, and it's my understanding that my IP address stays the same unless I unplug it. Is somebody trying to hack me? And if so, could they have somehow caused the disappearance of the mysql_fetch_row/array functions? Karen
View Replies !
Problem With Mysql_fetch_row() Vs Mysql_fetch_assoc()
Initially I set up some code to display table data using fetch_row() and then used $name = result[0]; $date = result[1]; $time = result[2]; - and so on - to assign the different values of the array into the specific variables noted above. That worked great. Then I stumbled upon fetch_assoc(). Cool. Now I can refer to the result by the name of the db field - it was always hard for me to remember what [0], [1], etc. were referring to. However, when I use fetch_assoc(), I AM getting result['name']; but I'M NOT getting result['postDate']; or result['postTime'];. Hummm. Interesting. Irritating. When I switch back to fetch_row() and use [0] (these are called numberic indices, correct?) etc., everythings okay again - I'm able to get the date and time as well as the name. I've triple-checked my db field names (they're ok: postDate and postTime) as well as my query strong (okay as well). I can't see where I'm going wrong. Anyone have any idea?
View Replies !
Mysql_fetch_row Doesn't Work
$result = mysql_query("SELECT * FROM page_content WHERE cID = '$cID'") or die ("Select Error"); $resultArray = mysql_fetch_array($result) or die ("Array Error"); It already connects properly and everything but when it gets to the fetch_array part, I get the "Array Error" error. I can't figure out why this doesn't work. mysql_fetch_row doesn't work either.
View Replies !
Mysql_result Vs. Mysql_fetch_array Vs. Mysql_fetch_row
I have a very general question regarding mysql_result function. I was reading a PHP/MySQL book and the example code after running a query used this syntax: $item_price=mysql_result($get_item_res,0,'item_price'); is this different from using: mysql_fetch_array or mysql_fetch_row. Which method is better and more efficient.
View Replies !
Handling Data Returned By Mysql_fetch_row()
The point is to make links in the end of each row just like in PHPMyAdmin. So after every row there would be links to delete row(delete row from database) update row (update row from database) the SQL syntaxes are clear for those functions just the PHP part is missing. I can make links after each line to those functions, but that is just a basic HTML and the page followed does not contain the row specific data!
View Replies !
Mysql_fetch_row(): Supplied Argument Is Not A Valid MySQL Result
Here is my script and when i get the data from a database it gives this error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in D:Fluke_Mambocomponentscom_confirmationorder_status.php on line 33 if you want to know where $my->username comes from it is defined from the user logged in at the moment becouse this file is included....
View Replies !
Check If The Dates In The Array $holi[] Matches $evalday (not In An Array)
What I'm trying to do is check if the dates in the array $holi[] matches $evalday (not in an array) but with limited success the data in the array is: $holi[1] = 2006-06-20; $holi[2] = 2006-06-28; $holi[3] = 2006-07-19; $holi[4] = 2008-06-24; $holi[5] = 2006-06-30; $evalday = date("Y-m-d", strtotime("+ 1 days"); if($evalday == $holi) { echo("For the purpose of this excercise, $evalday is a holiday"); }
View Replies !
Selecting Array Rows Based On An Array Of Field=>values
Here's the code i have: $db = array(); //main array $db['main'] = array(); //table `main` $db['main'][] = array('id'=>0, 'username'=>'joshfrench','userpass'=>'password','userlevel'=>'admin'); //row $db['main'][] = array('id'=>1, 'username'=>'bob_smith','userpass'=>'psswrd','userlevel'=>'user'); //row function trim_value(&$value){ $value = strtolower(trim($value)); } function fdb_select($fields = "*", $table, $where = false, $limit = false){ global $db; $retv = $db[$table]; //LIMIT RESULTS TO FIELDS if(strrpos($fields, ",") === false){$field=array($fields);}else{$field = explode(",", $fields);}; array_walk($field, "trim_value"); $all_fields = array_keys($retv[0]); if($fields == '*'|| is_null($fields)){$field = $all_fields;}; $field = array_uintersect($all_fields, $field, "strcasecmp"); $retvi = array(); foreach($retv as $num =$row){ foreach($row as $fname =$fvalue){ $fname1 = strtolower($fname); if(in_array($fname1, $field)){ $retvi[$num][$fname]=$fvalue; }; }; }; //DONE LIMITING TO FIELDS if($where != false){ //UP TO HERE IT WORKS FINE //LIMIT TO WHERE CLAUSE $retvj = array(); foreach($retvi as $num =$row){ //IN THE ROW foreach($where as $k =$v){ //IF ROW MEETS ALL REQUIREMENTS if($row[$k] == $v){ $retvj[] = $retvi[$num]; //Keep that row }; }; }; //DONE LIMITING TO WHERE CLAUSE }; $retvi = (isset($retvj)) ? $retvj:$retvi; //SEND A FINAL ASSOCIATIVE ARRAY return $retvi; }; print_r(fdb_select("*", "main", array('id'=>"1", "username"=>"joshfrench"))); the previous code outputs this: Array ( [0] =Array ( [id] =0 [username] =joshfrench [userpass] =password [userlevel] =admin ) [1] =Array ( [id] =1 [username] =bob_smith [userpass] =psswrd [userlevel] =user ) )
View Replies !
Multidimensional Array Syntaxt For Preg_split Array Using Submitted Textarea
I have two textarea's called textarea1 and textarea2. What i did was use preg_split to split the textarea into seperate rows that i could use for analysis like so $array = preg_split("/[ ]?[ ]/", $_POST['textarea2'], -1,PREG_SPLIT_NO_EMPTY); $array2 = preg_split("/[ ]?[ ]/", $_POST['textarea1'], -1, PREG_SPLIT_NO_EMPTY); then i used a function created for me by a nice guy on here called get_ending($filepath) which basically stripped off of each peice of text the "http://www" from every URL i put into the textareas finishing off i wanted to create an array that would input an expression such as: echo "<a href='$array[1]' target='_blank'><img src='$array2[1]' border='0'>"; into a text area on the next page. ALL of this works, except that i dont know how to properly loop throught he array so it'll properly insert the text into the textarea on the next page. For now, all it does is place the array information in the page, rather statically, i would like to run some kind of if then statement that says "while $array has some kind of text in it, keep running this operation of echoing the following expression adding 1 to the end of the array number" I hope that makes sense Any ideas? Code:
View Replies !
Take The Entire Array And Apply The Htmlentities Function To Each Array Element
what I want to do is take the entire array and apply the htmlentities function to each array element. So here is what I am doing: $result = $dbconn->query("select * from tablename"); while($case = fetch_array_html($result)) Here is the function: function fetch_array_html($result) { $arr = mysql_fetch_array($result); foreach($arr as $key=>$val) { $arr[$key] = htmlentities($val); } return $arr; } Here is the error I get: Warning: Invalid argument supplied for foreach() on line 129 What exactly am I doing wrong here? I can usually fix my own errors, but this one is dominating me.
View Replies !
Finding Elements Of An Array In Another Multi-dimensional Array
So I have 2 arrays: one contains userids. It may look like: user_id[0] =12, user_id[1] =30, user_id[2] =43 The other is a multi-dimensional array with fields like: user_info [0] = Array ( [user_id] =13 [user_flag] =1 [url] =http://www.example.com?index,0 ) user_info[1] =Array { Array ( [user_id] =120 [user_flag] =1 [address] =1234 Main St, Anytown, USA [url] =http://www.yahoo.com ) user_info[2] =Array { Array ( [user_id] =130 [user_flag] =1 [address] =134 Main St, Anytown, USA [url] =http://www.google.com )
View Replies !
Array Element Disappears And The Whole Array Collapses And Renumbers Itself
checkbox arrays do not hold their respective positions as do other field arrays that are established to store the contents of selected records. The problem is that when you "uncheck" one of the elements and then repost, that array element disappears and the whole array collapses and renumbers itself with only the remaining "checked" ones -- simply useless when dealing with records in a table where all the field array elements should be in sync. I consider it a bug -- why does the array have to collapse? Why can't it just hold a null value and keep its position? The only fix is to never hold checkbox values in an array. Store them in individual variables numbered like an array, then do an "eval" to retrieve the contents. Here's the whole thing in action: Code:
View Replies !
Sorting An Array Problem, (array/string Manipulation)
I have a function that I found on google, that goes through a directory and spits out a directory tree in an array, with arrays inside of arrays, and more and more arrays inside of arrays, depending on how many subdirectories are there..... Here is a sample "directory tree" it spits out. My problem is wanting to be able to create a new array containing only the paths to all the subdirectories it finds from this array, so it is with array manipulation... Not all paths are located in the topmost array's values, but some directories are within other subdirectories and so forth.. I'm stumped on how exactly to sort through this array, whether recursively or not to grab all the 'paths' in the array period. Code:
View Replies !
Sorting Sql Results In An Array Using Things Outside The Array To Sort Them?
I'm using PHP to connect to a database full of place names, and their associated post codes, latitude and longitude on the earth. A user types his or her post code into a form, plus a distance (in miles), and the script looks for other area codes (first half of the post code) within that distance. I can do that fine, but the results are ordered alphabetically by postcode, and I want to order it by the distance. Problem here, is that the distance isn't part of the array taken from the database, it takes the latitude and longitude of the area it's on in the while loop, and calculates the distance between the user's post code and that one, but it's not part of the array, so I can't sort the array using it. How can I sort it? Can I add the calculated distances to the array, and sort it using sort()? If yes, how do I add them to the array? Here's the page, just to explain better what the script does: http://navimaker.org/ed/owain/results.php?postcode=gl15&distance=34 Mess around with the postcode and distance vars. I'd put the source on here too but I'm doing all this over SSH and can't copy & paste very easily .
View Replies !
Accessing Array Values Inside A Multidimensional Array
I need to access a value which is inside in a multidimensional array... Suppose there is a form and where I takes all the form values inside an array named access..and I post the values into a different array. $registrationArray = $_POST['access']; Now I need to loop through this registration array and get values printed to the new variables... Suppose this is the array $access = array (fname,lname,date,year,month) How do I print the date,year,month values into different variable by looping through registration array..
View Replies !
Trying To Compare Array Values To A Value, Then Create Boolean Array
I have an array that returns data like this (see array below) The array[0] contains all the votes for one story as well as information that pertains to that vote, and the array[1] contains vote information for another story. What I need to do is check is a user_id stored in a session, is in the array, and then create a boolean array from that. For example, here I want to check if the user_id is featured in the first set of data, let's say my user_id is 74. Ok, so it is in the first set of data, so we set the boolean variable to true. Next I need to search the second data field for my user_id, 73. It is not featured here so the value in my array is set to 0. I need an array that returns values either 1, for true, your user_id was found in the table, or false, for your user_id was not featured in the table. They need to be in order of the story too. I'm having trouble one comparing the two variables against eachother, since the array is very deep, and two, creating the array on the fly. Code:
View Replies !
Adding To $_POST Array Is Not Reflected In $_REQUEST Array
Recently I wrote this: <? echo 'action = '.$_REQUEST['action'].' '; ?> <?php $_POST['action'] = 'newmember_split'; echo 'action = '.$_REQUEST['action'].' '; ?> My expected output was: action = action = newmember_split However my output was: action = action = How is this so. As far as I know $_REQUEST is supposed to reflect both $_POST and $_GET. I tried to find some information on it but failed.
View Replies !
Sort Array - [2] => Array( [id] => 232, [zone] => C, [color] => Yellow )
Array: => Array( [id] => 64, [zone] => a, [color] => blue )[1] => Array( [id] => 17, [zone] => b, [color] => grey ) Â Â [2] => Array( [id] => 232, [zone] => c, [color] => yellow ) Â Â [3] => Array( [id] => 36, [zone] => a, [color] => red ) Â Â [4] => Array( [id] => 178, [zone] => a, [color] => white ) Â Â [5] => Array( [id] => 10, [zone] => c, [color] => blue ) Â Â [6] => Array( [id] => 115, [zone] => a, [color] => orange ) Â Â [7] => Array( [id] => 345, [zone] => a, [color] => black ) Â Â [8] => Array( [id] => 19, [zone] => b, [color] => green ) Â Â [9] => Array( [id] => 206, [zone] => a, [color] => red )
View Replies !
|