473,889 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SELECT'ing from an arry?


$lines = file("list.txt" );
$l_count = count($lines);

for($i = 0; $i < 3; $i++) {
$var = $lines[$i];
}

mysql_query("SE LECT name FROM list WHERE name='$var'");

In the list.txt it would have data like:
Code:

One
Two
Three

And "echo $list[0];" would come up as "one".

I need to SELECT the name "one" and return the column data.

It doesn't select anything, even though it does get the data correctly
when echo'd. What's wrong?

OR am I going the wrong way w/ this? :x

Nov 6 '07
12 1378
The Natural Philosopher wrote:
Jerry Stuckle wrote:
>The Natural Philosopher wrote:
>>Austin wrote:
On Nov 6, 7:15 pm, The Natural Philosopher <a...@b.cwrot e:
Austin wrote:
>$lines = file("list.txt" );
>$l_count = count($lines);
>for($i = 0; $i < 3; $i++) {
> $var = $lines[$i];
>}
>mysql_quer y("SELECT name FROM list WHERE name='$var'");
>In the list.txt it would have data like:
>Code:
>One
>Two
>Three
>And "echo $list[0];" would come up as "one".
>I need to SELECT the name "one" and return the column data.
>It doesn't select anything, even though it does get the data
>correctl y
>when echo'd. What's wrong?
>OR am I going the wrong way w/ this? :x
I am completely baffled. What makes you think that Mysql has
anything to
do with a file called 'list.txt'?

Well if you flatfile something then sure it does...
Now ignore the irrelevant and input something useful.

I wansn't aware that Mysql dealt with flat files.

I cant see the point of using it with a flat file that has already
been opened another way..

I didnt think a mysql query worked without opening a connection to a
database.

Now, what am I missing here?

You're missing the fact he only showed maybe 2% of his code, and that
he's querying a MySQL database for rows that match the contents of the
flat file.
Now by what leap of faith did you arrive at that conclusion?
I read what he said.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Nov 7 '07 #11
On Nov 6, 4:15 pm, The Natural Philosopher <a...@b.cwrot e:
Austin wrote:
$lines = file("list.txt" );
$l_count = count($lines);
for($i = 0; $i < 3; $i++) {
$var = $lines[$i];
}
mysql_query("SE LECT name FROM list WHERE name='$var'");
In the list.txt it would have data like:
Code:
One
Two
Three
And "echo $list[0];" would come up as "one".
I need to SELECT the name "one" and return the column data.
It doesn't select anything, even though it does get the data correctly
when echo'd. What's wrong?
OR am I going the wrong way w/ this? :x

I am completely baffled. What makes you think that Mysql has anything to
do with a file called 'list.txt'?
i'm confused why he expects $var to equal anything but the last
element in the array $list.

Nov 7 '07 #12
dave wrote:
On Nov 6, 4:15 pm, The Natural Philosopher <a...@b.cwrot e:
>Austin wrote:
>>$lines = file("list.txt" );
$l_count = count($lines);
for($i = 0; $i < 3; $i++) {
$var = $lines[$i];
}
mysql_query(" SELECT name FROM list WHERE name='$var'");
In the list.txt it would have data like:
Code:
One
Two
Three
And "echo $list[0];" would come up as "one".
I need to SELECT the name "one" and return the column data.
It doesn't select anything, even though it does get the data correctly
when echo'd. What's wrong?
OR am I going the wrong way w/ this? :x
I am completely baffled. What makes you think that Mysql has anything to
do with a file called 'list.txt'?

i'm confused why he expects $var to equal anything but the last
element in the array $list.

Just a misplaced right brace...

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp\0\0\0j**** ****@attglobal. net
=============== ==
Nov 7 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
22963
by: Robert Chares | last post by:
Hello, I'm sure it has been asked a thousand times before, but still: How can I access a particular row in my MySQL table via PHP? The background is just to update the values of one row in the table via a html form with the old values already filled in. What I tried so far ist sth like this: $row=mysql_query('SELECT * FROM names WHERE ID=$entry');
6
1343
by: Jack | last post by:
Hello, <%@ Language=VBScript %> <% Response.Write "<FORM name=form1>" Response.Write "<select name=""select1"">" Response.Write "<option value=1>One</option>" Response.Write "<option value=2>Two</option>" Response.Write "<option value=3>Three</option>" Response.Write "</select>" Response.Write "</FORM>"
3
2412
by: Michael Qiu | last post by:
I hava a select component on my form. the width of the select component is fixed,so if the length of the option's shown string larger than the select component's width,how can i make the shown string wrap to next line? <select name=123 style="width:100px;height:200px"> <option value=1>abcdefghijklmnopqrstuvwxyz</option> </select> select component's width is 100px, the option's shown sring is abcdefghijklmnopqrstuvwxyz,if shown string's...
1
11350
by: John Hall | last post by:
We need to read a SQL database containing a mix of English words and Chinese Characters. We think we need to use the N'xxxx' to read the Unicode. We have one place where the SELECT statement works fine. Here is that statement: dim objCmdCategories as new SQLDataAdapter ("select distinct N'product_category' from " & _ "tblproducts where product_status=1 order by product_category", objConn) However, we can't seem to get another SELECT...
7
2291
by: brian.ackermann | last post by:
Hello all, I'm currently writing a tiny little bit of navigation to a page, and I've come across this stumbling block: Goto Page&nbsp;&nbsp; <select name="page"> <SCRIPT LANGUAGE="JavaScript1.2" > for ( var inc = 1; inc <= <%=nPages%>; inc++ ){ document.PageForm.page = new Option(inc, inc, ((inc ==
1
11587
by: Ahmet Karaca | last post by:
Hi. myds.Reset(); mycommand.SelectCommand.CommandText= "Select att1 from Ing as Ingredient, Pro as Product "+ "where Pro.ad='apple' and Pro.id=Ing.id"; mycommand.Fill(myds, "Product"); // Here is the problem listbox.DataSource = myds.Tables.DefaultView; // Here again listbox.DataTextField = "invid"; // Here again listbox.DataBind(); mycon.Close()
6
13036
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this is not an ASP.NET related question, but I know this group is knowledgeable and quick with responses. Thanks
6
28746
by: mabond | last post by:
Hi Is it possible to compare a vaule for a select case statement using a wildcard. e.g. somthing like Select case myValue case like "*ing" end select
1
8168
by: Veeru71 | last post by:
When I am SELECT'ing a CLOB column from command prompt, the output is getting truncated after a certail limit (8 K ??) How do I get the full data out of a CLOB column? Are there any string manipuration functions for CLOB fields to read it in multiple chunks ? Thanks in advance.
0
9802
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10780
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5825
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.