Arrays And While Mysql Functions
How can I get this array to work? I am trying to add data to an array for every row of data? This is a sellection of queries that I need to parse into an array so a function can use the arra to draw a graph. I am new to arrays how can I get this to work? Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Arrays, Functions
I know this has been covered, because I've been reading everything I can on the subject, but I can't seem to figure out how to pass arrays into and out of my functions. PHP Code:
Passing Arrays To Functions
[code] $job_status = array( "unassigned", "current", "completed" ); function gimme($name){ echo $$name; // this is in hopes to echo the contents of $job_status when gimme(job_status) is called } How can I get $name to be the ARRAY $job_status? I'm trying to keep this very modular so that I can also perform: gimme(job_type); among others.
Question About Arrays And Functions
$sql = "DELETE FROM " . $mosConfig_dbprefix . "foo WHERE foo_id = '" . mosGetParam($_POST, 'cid', '' )[$a] . "'"; was throwing errors and I fixed it be doing this: $cidx = mosGetParam( $_POST, 'cid', '' ); $sql = "DELETE FROM " . $mosConfig_dbprefix . "foo WHERE foo_id = '" . $cidx[$a] . "'"; My question is why didn't the first version work and is there a way to code it without adding the intermediate variable?
Passing Arrays To Functions
How do I pass an array to a function? This is what I have, and the second function doesn't seem to be getting the array somehow. I'm sure it's in the function declaration... function one(){ return $array; // yes, there is more to this function, and assume that "$array" is a real array } funtcion two($arrayArg){ // <- I'm sure the prob is here. print_r($arrayArg); // This isn't printing anything, when it does in one() } then I call: two(one()); Once again, I'm sure the prob is in the declaration.
Elements From Functions That Return Arrays
I'd like to access a single element from a function that returns an array; and I'd like to do it in a single statement. Here's an example. This is obvious. $a = explode(".", "this.is.some.text"); $b = $a[2]; So how can I do that in a single statement? $a = explode(".", "this.is.some.text")[2] // no $a = (explode(".", "this.is.some.text"))[2] // nope $a = [explode(".", "this.is.some.text")][2] // no way How close am I coming to the final result. My goal is to be able to nest them. I was looking for an answer in the array functions, but the ones I found don't return a scalar value, they return arrays in my cases.
How Do You Pass Functions Via Arrays Into Loops?
How do I pass a function through an array into a loop? I'll explain what I mean. I have a function (do_telcos) which just grabs a list of Telephone companies and their IDs and spits them into a dropdown box. I'm trying to use this in a form that I'm building from an array as follows: Code:
PHP MySQL Functions
Does anyone have any php funcitons already written for querying the database etc..?
Arrays In MySQL
Can I store an array into an SQL database and then take it back out and it would still be an array?
Arrays Into Mysql
The mysterious message: Couldn't add data to the CATLINK table:Unknown column 'Manufacturing' in 'field list' PHP Code:
MySQL Functions Are Undefined
I have php4 and mySQL. When I call a mySQL function such as mqsql_connect() I get ERROR undefined function. Please help, THe dll is in the folder but I have no idea how to resolve this, other people have also had this problem.
Php Mysql Api Functions - Speed
is there a difference in script overhead/speed when using mysql_fetch_array vs. mysql_fetch_object? Is there a reason to use one over the other in any given circumstance?
Fastest MySQL Functions
i was wondering if anyone knows what the fastest mysql functions/libraries there are. i was reading that mysqli is up to 40x faster than mysql, but wasn't sure if i should use the object vers or just the function based ones.. also, if there's anything faster?
PHP Is Not Recognizing MySQL Functions
Whenever I try to use a mysql function (such as mysql_connect("localhost","root","mypassword") with mypassword being my actual password), viewing the page in mozilla reveals this error message: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/index.php3 on line 14 I'm pretty sure that this means it has no definition for that function, and thus can't execute it. It does this for all mySQL stuff. I am doing this on a 9.1 Mandrake Linux installation with PHP v. 4.3.1 and mySQL 4.0.14. To install mySQL for PHP, I used urpmi php-mysql as suggested by my phpinfo() page. Both PHP and mySQL work fine on their own, just not together.
Mysql Time Functions
This represents 2 fields in a mysql database [login] => 2005-08-22 18:04:41 [logout] => 2005-08-22 18:05:08 I want to find out the difference between these 2 times. I don't have access to mysql's DATEDIFF function. How do I do this ? Its there perhaps, a web page that explains how ? I have looked at the date and time functions of the mysql manual but i don't understand it.
PHP Version 4.2.2 Mysql Functions
I have a collectionof PHP/MySQL scripts that used to work great when I was using PHP 4.0.x. However I recently 'upgraded' to version 4.2.2 and none of them work. I looked through php.net for info on this, but couldn't find what I was looking for. The script below works great on my old version of PHP, but I am always getting a "mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/htdocs/xxx/xxx.php on line 24" The script looks like this: Code:
Mail Functions And MySQL
Okay I have created a script that post user information to mysql database. Now I would like to be able to send a webpage to each user based on there place and state, but the code below sends to one user multiple pages. What is wrong with this code or is there something better to use to do this? ....
MySQL Query And Arrays
I have a 'links' category on Table A and I want to retrieve the links from the Table and display them in a list-like fashion when the page is called upon. How would I go about seperating the links from one another (there a space inbetween each link.. EXAMPLE: http://asdf.com http://asdasd.com http://asdfff.com), loading them into an array (or using the best possible method to acces them easily) and then displaying them in a list like fashion..?
Arrays And MySQL Querys
I can't get an $array[key] to be used as a select query on a mySQL database. I have a 'parts list' which displays on a page (works fine) and is a form. At the end of each row is a input type='text' (quantity) cell with a default 0 The quantity can be altered. At the bottom of the table (form) is a submit to basket Button echo "<form action='basket.php' method='POST'>....
Arrays Working With MySQL
How can I grab a certain field of a Multi-Dimensional Array using the ID. I have set for that Array? I just want to be able to create a simple function to do pretty much what this function does, but for an array. Code:
Data/math Functions With Php/mysql
Hey everybody, I have a tricky problem that i need to solve... I'm currently using apache/php/mysql , developing a custom ticket system... now i'm working on one of the final parts which are reports... here is the scenario: I have a few rows of dates, such as when a ticket was opened and when that same ticket was closed... ie: open_ticket, closed_ticket I need to calculate the number of days it took me to complete each ticket, then i need to calculate the MEDIAN time it took me to complete tickets... see, kind of tricky, I noticed that mysql can do averages, but can it do MEDIAN values?
Passing PHP Arrays To Mysql Best Solution
I am relatively new to PHP and until now I have only needed to use relatively simple php/mysql solutions. I am working on a problem where I need to store CD information (Artist Name, Album Name, Track Names, Catalog Number) I am working on a solution with two tables "album" and "tracks" and I am using the catalog number as a key to link the two. The problem I am having is coming up with the best way to populate the tracks table as there are several tracks for each release. I am assuming that an array would be the correct way and maybe a dynamic form to input the tracks where you decide the number you need to add and this then creates a form with "n" input boxes?
Insert Multiple Arrays Into Mysql
I am having problems writing the code to generate my SQL INSERT query. I have 3 arrays and one static variable ($cat_number): $track_name[] $music_link[] $track_number[] $cat_number Should I be using a foreach command. I know how to insert multiple values but its generating the query that i'm not sure about. INSERT INTO table (track_name, music_link, cat_number, track_number) VALUES (var1,var2,var3,var4), (var5,var6,var7,var8), (var9,var10,var11,var12); I don't want to store the actual array in the dataabase, I am just using an array to catch the data.
Multiple Selections, Arrays, And MySQL
OK this place has been great with explaining things that are way over my head, now I could use a boost to get my brain working again. I have a form with a drop down menu with multiple selections. When the form is submitted it shows up in the DB field as "array", as well as the page where I how the form's info. I think I have to set up an array, and loop(?) it, or do I need to implode the array? And how and where would I put these commands on this incredible messy form page. Would someone mind helping me get started? Here's the form: (please don't make fun of me, I used to a Dreamweaver extension to create the form using PHP, before I decided to try and write this stuff myself. I am re-doing the form but this actually works for now, so I am using it. Code:
Sorting Arrays Retrieved From A MySQL Db
I am trying to make a news system. I have done it, but the news are listed with the last on at the bottom. This makes it kind of troublesome to read the latest news when you enter the site and there are a lot of news items, cause you would have to scroll down. PHP Code:
Populating Arrays From MySQL Query
I have the following code: http://pastebin.com/746601 The field 'material' in 'is_material' contains multiple values for each record in 'is_details'. Because of this I have used 'is_material_lookup' as a reference lookup table containing the 'style_code' and 'material_code' which refer to their full details in the respective tables. Currently I have got the script outputting all the details and one material then in the next block of data, repeating the details with a different material. What I would like to achieve is having 1 block of data with a list of all materials in that, instead of the repeat, but sadly I can't know exactly how to do it.
How To Insert Arrays Into Mysql Database
This is my order.php file. Now I try to make a new php-file for processing the ordered items on this page, into another table "ordered_products" in the database. I want to INPUT following values into the table "ordered_products": 'order_num', 'order_item' and 'order_ant' I know how to insert rows in a table using the INSERT query, but I don't know how to do it while looping the arrays. I have to fetch the arrays from this page, and insert them row by row in the "ordered_products" table. Code:
Using Arrays With Mysql Query Results
im currently in the process of making a piece of code that will firstly take all the data from a table in mysql and then assign it to an array. This data will consist of several different rows of data each with different infomation for each field in the table. i want to be able to use an array in a loop so that depending on which number of the loop is on will change the infomation that is assigned to a certain array. Code:
Merging 2 Mysql Resultant Arrays
im currently executing sql queries on two seperate mysql servers. i take back each of these results into individual tables to display them. What i wanted to do was perform a merge of the two arrays, so that i could order the results by my "TimeStamp" field. When i try to perform a basic " $mergedresult = array_merge($result, $isaresult); " i get the following. " Warning: array_merge() [function.array-merge]: Argument #1 is not an array in C:Program Filesxampplitehtdocsseatpub.php on line 164 Warning: array_merge() [function.array-merge]: Argument #2 is not an array in C:Program Filesxampplitehtdocsseatpub.php on line 164 " Im rather new to this and so havent delt with arrays before, but im under the impression my results from the sql queries, are Assoc arrays. can these be merged ? do i need to use an alternate php function ?
MySQL: External SQL Functions Exported By DLLs
Sorry for being a little off-topic, but I guess PHP users are often MySQL users too. We have a few rather advanced calculation routines developed in C++. Currently we are using a Sybase ASA database for our app. and these routines are accessible by so called external functions exported by a DLL (dynamic link library) that we wrote in C++. Sybase supports this quite nicely. The client app can call such routines by: "select get_roof_angle() as angle from dummy;" or ":angle = call get_roof_angle();" Now we are checking if other databases can provide us with similar abilities. So I just wonder if MySQL supports the ability to call a routine exported by a DLL? If yes, does anyone know the SQL syntax to declare it in MySQL.
Session.save_path Appears To Affect Mysql Functions
I was installing a script did not want to place session variables in the standard php directory. After changing the session_save_path in the scripts .htaccess file, the mysql_connect stopped functioning, function_exists('mysql_connect') returned False. I suspect the whole mysql library stopped functioning. Is this a known bug in PHP's mysql handling?
Pesky Checkbox Arrays And A MySQL Song Database
I'm not one who likes to ask for help, so for the last three days my brain has been turning to mush while I try to create a DJ Request Song Wish List. Anyone who can help me out will be saving me from severe insanity. :) My goal is to: 1. Display search results for song title, artist and genre. (accomplished) 2. Allow the user to add songs to their Wish List. This is done by displaying checkboxes with the corresponding value equal to the songID. (working on it) 3. Allow the user to update their wishlist by adding/deleting songs. So far I have a form that retrieves the song info from a database in a repeating region. In Dreamweaver: <input name="songID[]" type="checkbox" id="songID[]" value="<b><?php echo $row_RecordsetSearchResults['Title'];?></b> by <?php echo $row_RecordsetSearchResults['Artist'];?>"> This puts the corresponding songID number into a checkbox value, which in turn is submitted by form POST action to the following page as an array. To process this array I have: if(isset($_POST['songID'])) { $songID = $_POST['songID']; print '<p>Song IDs:</p>' // process items $n = count($songID); for($i = 0; $i <= $n; $i++) { //See if the values are being passed from POST echo $songID[$i]; echo '<br>' } $songsInsert = '*'.implode('*',$_POST['songID']).'<br>' $insertSQL = sprintf("INSERT INTO wishlist (Username, Title) VALUES (%s, %s)", GetSQLValueString($MM_Username, "text"), GetSQLValueString($songsInsert, "text")); mysql_select_db($database_ToneDeaf, $ToneDeaf); $Result1 = mysql_query($insertSQL, $ToneDeaf) or die(mysql_error()); } The problem is, I'm using implode. It does store the songs, but only as one long block of text. So if the user picks "New York by Frank Sinatra" and "Hot In Here by Nelly" it is stored as "*New York by Frank Sinatra*Hot In Here by Nelly*" Obviously this gives me no options to make this actually readable, let alone allow the user to remove one of those songs from their list (both would be have to be removed.) Also, referencing only the songID number as stored in the music database doesn't seem a good option, since the song database will be changing frequently and song data may be overwritten. Not sure if there's a viable workaround there. Originally I wanted to store Title, Artist, Genre under seperate columns so I could link them to something like "See more songs from this Artist." However the more I read about arrays and multidimensional arrays, I realize I'm not ready to go there yet. (I just started learning PHP two weeks ago.)
Comparing Values Of 2 Arrays Combined With Mysql Field Names
I am trying to create an edithistory table that has a text column into which I will put a string that can be read using strtok later to revert changes if necessary. I want to build this function so that it's dynamic enough to be applied to every table so that I don't have to write one for each table that might be updated. When a row is added to any table (a new entry), it retrieves the next available editid # from the edithistory table and assigns it to that item in the "edits" column for its row in its own table. Every edit made is a new entry in the edithistory table (entryid auto_increment primary key), and the editid is a reference back to the object being edited. Code:
DBM Functions:: Undefined Functions Error
I have been trying to use the DBM Functions (dbmopen etc) in php but always get an undefined funtion error. Do I need to load something or change something in the .ini file to get it to work? thanks MIke
Arrays Within Arrays, How To Split
I have been stumped on this one and it is probably easier than I think it is, especially since my brain is fried. This is what my array looks like: array(7) { ["injuredPerson"]=> string(0) "" ["dates"]=> string(0) "" ["describe"]=> string(0) "" ["location"]=> string(0) "" ["type"]=> array(3) { [0]=> string(8) "abrasion" [1]=> string(10) "amputation" [2]=> string(12) "asphyxiation" } ["part"]=> string(0) "" ["times"]=> string(0) "" } This is actually an array of information from a form check. I have the error handling check the form and depending on if there is an error or not, the array gets populated with "" or an actual value(s). I am testing a checkbox area of the form (the name is type, so type can hold an array of values, thats why it currently contains abrasion, amputation, and asphyxiation). I have had no problem going through the array until I get to the area with an array within the array. Let me give you some code so you can see how I am doing this:
Searching Arrays With Arrays
ive looked through alot of the array search functions and i dont think any of them support arrays as the "needle" to search for. so say i had a numeric array, $array1 with say 5 elements, 0-4, each element is a single word, lowercase. say i had another numeric array structured the same way called $array2 with say about 5 elements, 0-4. Is there a function which i could use or does anyone know of an easy way to search every element in $array1 and compair it through each of the elements of $array2? and if a duplicate is found in $array2 have that element be removed or unset? im sure this can be done probably easy with some kind of loop function, but thats my weak point right now in php and im working on it.
Do We Need This Functions?
I'd like to check with others what are the least used functions in PHP, since I think that it is becoming more and more filled with unuseful addons while missing useful extensions like SOAP (to name one).
PHP Functions
I have a serious problem, that I hope you here at DevShed can help me out. I have been using PHP for a while now and I love it, I think its a great language. I have learnt quite a lot already...but there is one thing that I have had trouble with and thats writing my own FUNCTIONS! Im fine with the built in functions etc, but I just cant get my head around bloody USER DEFINED FUNCTIONS! I have read books, completed many tutorials and just when I think I have it sewn up, something else crops up and Im back where i started. I would be very grateful if someone could take me through the workings/example of a custom function. e.g - echoing in a function, returning values.
Using PHP Functions On Different Url
I want to extract the size of images located at a different url Is it possible to use the GetImageSize() function to do this? from http://www.site1/myscript.php I have tried - $url = "http://www.site2/image_name.jpg" ; $size = GetImageSize($url); But I get a error. Is there a way of using functions such as GetImageSize(), chdir(), etc from one site to extract data from another site? Both sites are mine and I have made the directories 777 The reason I want to do this is because I hold 100's of images on one site, but wish to use them on a second site without having to keep copying over all the images as it will be difficult to keep up to date. But I need to use php to extract and minipulate the images before displaying. Does any kind php guru know a way of doing this?
XML Functions With PHP
Anyone know where I can find some tutorials or good usefull examples on parsing XML with the XML functions? I really need help with this stuff, but I cant find any docs anywhere, help would really be appriciated.
C Functions To Use With PHP
We have a bunch of C and C++ functions pre-developed in our organization. To make a web frontend, we would like to use PHP but we don't want to recode all the C functionality. I recall reading a while back in the manual that C functions can be integrated into PHP, compiled perhaps, but I cannot seem to find it now.
Php-functions
Do any of you know if PHP supports a function to check a file. A same sort of function like in an Unix-environment the function "file" is: to check what kind of file a specific file is.
Functions
Is it possible to install new functions without reinstalling PHP,on a unix system?
XML DOM Functions
What about actually creating an xml doc on the fly, and saving it out. Does anyone know of any info or examples on this to point me to before I go hacking away with nothing but the xml dom function info from the manual? The manual is great, yes, but its usually the user comments that help in figuring this stuff out, and nobody talks about creating xml documents.
Functions!!
What I've done is I've got some code which displays the question and the wrong answer, however I'm trying to email the user who has set up the quiz, the info, which includes the wrong questions. The thing I don't want to repeat the code, but rather place this in a function, but it looks rather tricky, when I try to implement this. Code:
Min And Max Functions
If I have a series of integers, how do I get the minimum (or maximum) value NOT equaled to 0?
Web Functions?
I'd like to post some news content on my web page from another website. Are there built in php functions that will allow me to do this?
|