Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Help Needed Using Arrays In Query


I am try to use an array in a MySQL query using the in function. This requires a "," between each array entry but not at the end of the array. I can get a "," in between but I am left with one at the end. How can I get rid of the last ","?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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..?

Query About Empty POST Arrays
I started programming in PHP recently and have a query about empty
$_POST arrays. I can see two scenarios when this could happen.

1. When some tries to directly load the page to which data is being
posted (for example, opening www.foo.com/xyz.php directly when a form
action is xyz.php)
2. When the user clicks the submit button without entering anything.

I am aware that Javascript validation can take care of the second case,
but it's unreliable. What is the accepted way of handling the above
situations on the server side?
Do I just reload the calling page if the array is empty?

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.

Arrays, Query Results And Select Box
I want/need to pre-select a drop-down box with a value if it's present in both a lookup table and user account table. After wrestling with this for a few hours I give up.

i know this can't be this complicated, but apparently i'm missing something, so if anyone can suggest a way to go about this i'd be a little more sane. The idea is to have the user value already selected then when they change the value i'll update their account.

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:

Disable Passing Arrays In Query String?
Is there any way to stop PHP from turning a query string like this: ?var[] into an array when it is read by $_GET['var']? I have quite a few input validations that are easily screwed up by this strange (and apparently undocumented???) feature...

Help Needed..
I am Ronny from Germany, so please excuse my English. Since early 2002 I am trying to solve th following problem:

I am trying to programm a meta search engine - which fetches the results of about 10 search engines. Now I solved the problem with fopen(), fread() etc. But it is to slow - and so my question is :

Is it possible to make several http requests at the same time in PHP or do you know a Perl Program where I can put in maybe 10 URL´s and the results where saved in an array which I can use in PHP???

NOW() Help Needed
I am putting data into a mysql database, the database tells me the time a user signed up, this is placed in the table using the now function but the date always shows as 2002/11/06 not how i would like it, i want it to view as 06/11/2002, i think it can be manipulated in many ways.

Also on manually updating a further table i have to place in a date manually, when i put the date in the fiels using phpmyadmin the date still looks like 2002/11/06, i try change the value but with no joy.

Help With Regexp Needed
Hello,

I'm coding a simple templating system to fit in to my simple CMS system. The way this will work is that the administrator of the CMS can edit the template (stored in a db), and insert 'snippets' into the template. A snippet is a piece of code (also stored in the db) which may have PHP code in it, which will then be eval()'d.

A simple example would be:

<html>
<head>
<title>[[title]]</title>
</head>
<body>
[[menu]]
[[content]]
</body>
</html>

The snippets here are [[title]], [[menu]] and [[content]]. This is fine as long as I know exactly which snippets will be in the template, but that's not always the case.

So what I want to do, is search through the string containing the template, find all the snippets and save these in an array.

My guess is that this'd be done with regular expressions, but I'm still very new at those, and have no idea how to do what I want.

Does anyone have an idea about how to do this?

Thanks!
Alex

PHP Developers Needed
hello,
My name is Joshua Abbott and I am project administrator of the AWHCP project on sourceforge.net. Our project is aiming to create an advanced web hosting control panel of 350 end user features (once final release) and a lot of security features in a packaged OS called extremeserv-linux @ extremeserv-linux.com . We desperately need PHP Developers to help in this endevour. So, if you are interested or want more information please email URL

Help Needed In Sending SMS With PHP
I want to know the process and the Implementation of sending text SMS to mobile phones with PHP. Is there any article regarding this? or any code example?

Nusoap & XML Help Needed
I am getting below result when accessing a web service.
Now how can I separate the values and assign them in variables for further use?

Help Needed With DB_DataObject
I have just adopted a PHP project and need some help understanding
DB_DataObject. I've looked around on the web and can't find a simple
explanation.

Basically, my MySQL database has no tables. I have a createTable.php
script which I believe is a standard script, it runs but tell me "NO
TABLES". There is a function in the script called _createTableList()
which is looking for tables not finding any (I don't really
understand why there should be pre-existing tables when the script is
supposed to be creating them...)

I have .ini files which seem to describe the schema, and classes which
correspond to the entries in the .ini file - but no SQL, and I do not
understand how to get the schema into the database. I believe the
environment is set up correctly for the script to find the .ini files.

I hope that was clear, and I hope somebody here can advise me - I'm sure
it's simple enough for somebody who knows what they're doing with
DB_DataObject!

Using PHP5 btw, if that matters.

Help Needed With Nntp
Im having trouble with a script trying to display newsgroups.
The script just hangs when trying to select a newsgroup (fget command)....

New Line Help Needed
I'm trying to insert a newline character into the string below for an
<INPUT TYPE="image" ALT= tag but when I hold the mouse over the image
I see the string but without a newline break in the string - how do I
get the line to break?

Sql Optimize Help Needed
SELECT * FROM post WHERE forumid=1 ORDER BY ctime LIMIT x,10

ctime=creation time
both forumid and ctime is index separately
it take too much time when x is so large.
how can i optimize this query?

Help Needed In IMAP+PHP
I am having a mail client script, which will read and send mail to mail
server, using IMAP. When i am sending mail with attachment through
forwarding, the attachment is not getting attached correctly, Plz any
one can help me to come out of the problem.

Note : I am using PHP 4.3.10 + IMAP + Apache +Zend Engine v1.3.0



URL Variable Needed
For a specific purpose I need the complete url displaying in the Url bar in the browser. Is there any function which provides that?

Advise Needed
I've no access to mysql NG, so I ask here.

We are looking for a system where user pay for having their article on
homepage.

Only 5 articles are shown every time.
The length of the service is 2 weeks.
The articles should be shown equally between clients.
If a user select a particular object in search engine, then coming back on
the homepage the shown article should reflect their need.

How to create a mysql query to get equally chances between articles ?

If only 2 announces of 5 are bought, I then want to fill the free places
with professionals articles.

I'd like to get random article from professionals, but not 2 articles from
the same pro. How to do so ? also with query (not with PHP)

If isn't possible, on PHP should I get all announces then try to find
randomly between results ?

Reg Expression Needed?
I'm retrieving some content from a DB but I would like to get first couple sentenances from the content and display this, I don't for sure if I have to use a regular expression to do this, but any assistance would be much appreciated.

PHP Script Needed
Question:
Where can I get a script(s) that do this:
http://network-tools.com/analyze

To be more precise, I would like the script that:
prints visitor's IP, monitor resolution, referral link, colors depth,
scans ports etc... etc...

I have been searching hotscripts.com for few days, came out empty
handed...

Is_uploaded_file() Help Needed
I'm using the is_uploaded_file() function to check if I'm uploading
via Http - I am using copy() and when I use the is_uploaded_file()
function it returns false - am I using the wrong upload method?

Help Needed With Script
I am quite new to all this and have stumbled at the first gate.

Can anyone tell me what is wrong with this?

<?php

$connection =
mysql_connect("domain","databaseusername","databasepassword");

$sql = 'SELECT * '
$sql .= 'FROM `PageElements` '
$sql .= 'WHERE pageid = 1 LIMIT 0, 30'

$result=mysql_query($sql,$connection);

while ($row = mysql_fetch_row($result)) * error message refers to this
line
{
for ($i=0; $i<mysql_num_fields($result); $i++)
echo $row[$i] . " ";

echo "
";

}
mysql_close($connection);
?>

I am getting the following error message:

Warning: Supplied argument is not a valid MySQL result resource in
/home/nprie/public_html/index2.php on line 26 (i have put an asterisk
next to line 26 above) as above script is a fragment of a php file.

Pattern Syntax Help Needed
I am trying to insert an astrisk (*) in front of a particular Selection field in an HTML file. The purpose of this would be to mark fields that have missing or incorrect data from a form post. But alas, I am having trouble getting the pattern syntax right. This is what I have so far:

Help Needed On Stored Procedures
I need some help manual or some tutorials on MySql stored procedures. Please send me some link or some matter from where i can start the store procedures.

GROUP BY Php Syntax Needed
I'm having trouble figuring out the PHP syntax to display GROUP BY results.

Here's my MySQL query:

PHP Mail() Security Fix Needed
Hello, all! Have been reading and searching, but haven't found an exact fix for my problem.

On our new web site, we found ourselves unexpectedly suspended because of "spam violations." After a frantic morning trying to reach a person who could help, I finally found someone who explained that our mail scripts on our new site were being exploited by spammers to send mail via our mail server.

First, the structure: We use a "shopping cart" solution that uses the PHP mail() function to send a notice that an order has been placed. I took that code, and modified it to send us alerts and form data from a number of different forms, depending on what the site visitor was looking to get from us, (i.e. request for quote, comment on site, etc.) In each that I modified, I designate a variable - $mymail - to hold the destination email address. For example:

$mymail = "dan@mysite.com";

At the end, it sends via PHP the following command:

mail($mymail, $mysubject, $themessage, "From: $mymail")

I have read on other threads on this forum, that if I "hard code" the email address, I will eliminate users from exploiting this command to send spam via our mail server, because what was once $mymail - and could probably be modified by a spammer/hacker - is now "hard coded" to, for example, dan@mysite.com. The execution command would then be:

mail("dan@mysite.com", $mysubject, $themessage, "From: dan@mysite.com")

What're some ideas on the feasability of this? Will it eliminate spammers using our site's mail server, by restricting delivery to just me? Or is it a wasted-time fix?

I have also been pointed to a formmail-type script which provides more security. Is that a better option? (Probably this will be my implementation in the long run, but I'm looking at a quick fix for today and the next day or two until I re-configure for the advanced fix.)

Chat Room Needed
I'm in a need of a chatroom for my website, and I'm assuming PHP would be the best option. There is one feature I must have:

I need to be able to assign a user mod powers so any time he logs in, he'll have that power. I also would like for his text to show up in a different color than everyone else's.

PHP And Dreamweaver Recommendations Needed
Somebody on here recommended Dreamweaver with PHP. I am coming from
(still using really) ASP and ASP.NET. PHP is more like ASP and not a
whole lot like .net, but I wanted to know how Dreamweaver will help me
with PHP. Is it easier to make a website "prettier" with Dreamweaver?
Just need guidance on why to use Dreamweaver with PHP. I am using
HTML kit or notepad and, of course, Google. Usually use the languages
and objects for hitting databases.

I am a good coder, but horrible artist and was hoping the Dreamweaver
combo might just be the ticket.

Open Source Needed
I am planning on making a supply and demand system. It looks a little
bit like an auction, with the following procedures:

1. Seller can add a product he is willing to sell (he has to choose
from a predefined list of procucts and categories). He gives the price
he is willing to make.
2. Buyers can browse through the database of predefined products, and
see if someone is offering a specific product.

Does anyone know of an open source project, capable of doing this ?

Striping Data Help Needed
I have a need to completely remove links from a large number of text documents. I know that I could simply use the "$strip_tags()" functon. However, I have been asked to remove the entire link, text and all. There are several links per document in random locations throughout each document.

So, how could I remove text from between <a and a> and then remove the leftover <aa>? (Or similar method) Is this even possible?

Stripping Data Help Needed
I'm taking text from a textarea object and want to strip out
characters other than A-Za-z0-9 before I send the data to MySQL table
- is there a function I can use to do this in PHP?


PHP/MySQL Developer Needed
I am seeking a developer to take over writing and maintaining
approximately ten small PHP modules, which retrieve and parse web data
and store it in a MySQL database. Required skills are regular
expressions, MySQL and OOP in PHP 4 or 5. If you are interested, please
contact me at: dev at modsoft dot net

Help Needed With A Regular Expression...
I'm creating a mini CMS that will store content in a MySQL
database. What I am trying to do is parse the content and replace
certain keywords with a link. The keywords and associated links are
kept in a MySQL table.

Here is an example.

$keyword = "Widgets Technology Co.";
$location = "http://www.widgets.com/about";

$keyword2 = "Widgets";
$location2 = "http://www.widgets.com";

$content = "We have the best Widgets at Widgets Technology Co.";

I want to parse through $content looking for $keyword and replacing it
with:
<a href="$location">$keyword</a> (this I can do with no problem)

but I am going to be looping through a series of keywords (phrases)
sorted by length (longest to shortest) that may or may not contain
other keywords such as the values above for $keyword2 which would
cause nested links and other nonsense.

so what I'm needing is a regular expression that will find the
$keyword (phrase) that is not already between "<a href =" and "</a>"
so that it will not try to relink it.

so far, this is the regular expression that I have, but does not work
properly:

[^(^<a href=)][^(>)]($keyword)[^(a>)$]

Help Needed To Build An Array
I have a table with something like

ID PARENT

0 | -1
1 | -1
2 | 1
3 | 1
4 | 2
5 | -1
6 | 4

And i want to build an array so i can output the data in the form

0
1
|--2
|----4
| |----5
|--3
5

Where 2 is a child of 1, and 4 is a child of 2 and so on.
I could create an array like $data[$id][$parent] but how would i output the
data where i get all the children of, say, ID=1 and all the children of ID =
4.
What would be the best way to achieve the above using MySQL db and php?

If i read all the data sorted by PARENT i might be able to read the whole
table at once and add all the data to one array?

Small Piece Of Php Needed
I just need a widget of php if anyone has somethign similar to hand.

I need to create a .php file that will take an input (&type=xxx or
yyy), run a piece of javascript in the browser (its the google
analytics javascript which i have here) and then send the user to
download either Install1.exe or Install2.exe depending on the value of
'type'.

At the mo, i have two links that link straight to one of two .exe
files. However, to make analysis easier, i want to have those links go
to a php page, which will run the javascript in the browser, thereby
getting google to log the download of the file, and then 'redirect'
the browser to download the correct file, so it appears seemlessly.

Multiple Checkboxes Help Needed
I'm using MySQL to display data on a web page - fitting about 10
records of data per screen - I'm including a checkbox with each record
so that I can check it and when the submit button is clicked the
called .php script will delete those records that are checked.

I'm creating the records from the table with the checkboxes ok (I
think):

<INPUT TYPE='checkbox'
NAME='frm_chk_delete[$php_delete_counter]'>Delete

I use a php counter var to give each checkbox record item a unique
NAME and this seems to work OK - producing
frm_chk_delete[0]
frm_chk_delete[1]
etc.

The problem I'm having is the POST called script - I don't seem to be
detecting enabled checkboxes to delete them:

$php_mem_name = Trim(StrToLower($php_name));
$php_SQL = "SELECT * FROM basics WHERE member_name =
'".$php_mem_name."'";
$php_resultID = mysql_query($php_SQL, $php_linkID);
$php_delete_counter = 0;
while ($php_row = mysql_fetch_object($php_resultID))
{
if ($frm_chk_delete[$php_delete_counter] == 'on')
{
$php_SQL = "DELETE FROM basics WHERE member_name =
'".$php_mem_name."'";
$php_resultID = mysql_query($php_SQL, $php_linkID);
}
$php_delete_counter++;
}



Looping? Don't Know How Many Times Needed?
I want a page to print out a lineage table. So, I have the first dragon's mom ID and dad ID, and then I want it to print out that dragon's mother's mother ID and dad ID, and that dragon's mother's mother's mother ID and dad ID, and so on.

Wrong Version Of DBG(2.11) -> 2.12 Is Needed...
I use Linux RH 9 and Phped 3.1 and recently downloaded latest sources of dbg and i think it's is installed all right in my php4.3.2 cause i see in phpinfo() a dbg enable row.

But when i try to run the Phped debugger, it doesn't work...

Wrong version (2.11) of php debugger detected.

DBG 2.12 is needed to start debug session.

Where i can download?

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.

Can Php Create New Folders On Webserver As Needed?
thread formally known as "can php create new folders on webserver as needed?" has changed...

i know php can upload files, but can it create a new folder on the webserver?

i am trying to create a "directory" with each person having his/her own folder for images. As a new person joins, i want a new folder that is named after him/her created for storage of his/her personal images.

if php can, please let me know of scripts or functions that can be used to create new folders on a webserver...

Advice Needed On Auto-redirect
I'm not quite sure how to accomplish the following:

1.) There is a webservice with a login form (let's call it login.php)
2.) Once you enter username / pwd you will be forwarded to another page. You cannot add variables in a query there directly (let's call it main.php)
3.) That new site uses a session management
4.) I want to read out the provided text on that new page
5.) After logging in I can't call that new site (main.php) without adding the correct session parameters:
This will not work: http:/www.domain.com/main.php (giving out DB error)
This will work: http://www.domain.com/main.php?session=31ae0ef85c3c

I have found a browser emulator script that does the automatic login:

Help Needed In Converting An Excel Formula
I am trying to put an Excel formula into phpcode (or mysql if possible). Basically it's for calculating distance using coordinates:

I have (in Excel):
B2=Earth radius (miles)

B4=Coordinate A latititude
B5=Coordinate A longitude

B7=Coordinate B latitude
B8=Coordinate B longitude

B10=Distance between 2 coordinates
B10 formula is:=B2*2*ASIN(SQRT(SIN((B4-B7)*PI()/180/2)^2+(COS(B4*PI()/180)*COS(B7*PI()/180)*SIN((B5-B8)*PI()/180/2)^2)))

Anyone knows if this can be done easy?

Help With Turkish Characters Desperately Needed!
I have been coding in PHP/MySQL for a few years, but have never had to deal with foreign characters before, and have come accross a problem.

I am setting up a table of event types, which has an ID, an english event type, and the corresponding translation in turkish.

I am manually entering these characters into the database, using phpMyAdmin, and am coming up with this problem:

I am trying to get this forum to display the actual character, but seems like it has encoding problems as well, so will only print ASCII. Here it is though!
When entering " &#304;&#351; temaslar&#305; ", the database actually stores " Ýþ temaslarý " instead... So some characters are being stored fine, but other characters aren't. If I use the ASCII codes istead of the actual character, the search system I have will not find the results, if the user enters the charecter itself instead of the ASCII code.

Another issue I have, is with some company names that contain turkish characters. I want to have a search facility, that allows users to search for companies. The problem is that some users will not have turkish characters, and so will enter the corresponding english character instead, but I would still like the search forum to find the results.

Example: Öbur is a company, but I would like it to be found when searching for Obur as well.

Any thoughts, hints or tutorials would be much appreciated.Please bare in mind that I know very little about encoding, but from what I understand, the pages should be unicoded, thats all I know!

Simple Connection Between PHP And Access (Help Needed)
I have an access database which I use to demonstrate Java - ODBC
connectivity and it works perfectly fine. This allows me to assume
that the Data Source name definition is OK.

I tried to access the same DSN (system DSN) thro' PHP and the
following error is displayed.

Warning: odbc_connect() [function.odbc-connect]: SQL error:
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified, SQL state IM002 in SQLConnect in
D:AjithTeachingPHPExamplesphpdbmstest.php on line 8
Connection Failed:

In summary: Database is there, DSN is defined, can access the DSN via
Java but not with PHP (or ASP).

Anybody who knows what the problem and the solution is?

MySQL Date Field Help Needed
I have a Date type in my MySQL table - I'm trying to do a query on all
rows within the last 30 days based on that Date field - I'm having
trouble figuring out how to form the query?

$php_SQL = "SELECT * FROM basics WHERE creation_date =
DATE_ADD(creation_date, INTERVAL -30 DAY)";

Help Needed With Tiger Tree Hashes
I am trying to generate tiger tree hashes the same way as directconnect
does, but I am failing.

I checked the output from php with the reference vectors from
http://www.cs.technion.ac.il/~biham...ssie-format.dat
and they appear to be different!

echo bin2hex(mhash(MHASH_TIGER, 'abc'))."<br/>";
outputs
f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951
instead of
2AAB1484E8C158F2BFB8C5FF41B57A525129131C957B5F93

and, for example,
echo bin2hex(mhash(MHASH_TIGER, 'message digest'))."<br/>";
outputs
951a2078cbf881d91c441e754830cf0df6295aa51aca7f51
instead of
D981F8CB78201A950DCF3048751E441C517FCA1AA55A29F6

What am I doing wrong here?

Reordering List Help Or Algo Needed
So lets assume I have a list of tasks in db table (table looks like:
ID, task, sort)

And I want to reorder the task list without updating all the records in
the table. I dont want to run a sql update stmt against every record to
update the "sort" field.

Any other easy way to do this? there has got to be a simple algo out
there.


Copyright © 2005-08 www.BigResource.com, All rights reserved