473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Question about reading an array

I need to insert email address into a table, before that i need to make sure that this email address is not already in the table. to check this i used =

if(in_array($email, $emailrows)) = This works however it only reads the value of email in the First row only not the remaining rows in the table.

please provide the code to check all the rows in the table for the Email field.
Oct 27 '07 #1
4 1024
Lumpy
69
Any chance that we can see the code you have that is running your query. That might help to get a better idea of what your doing and where the code might need a little tweaking.
Oct 27 '07 #2
Expand|Select|Wrap|Line Numbers
  1. //sql?
  2. <?php
  3. $query = "select pk from tablename where email = 'emailaddress'";
  4. $result = pg_query($query); //mysql_query() for mysql
  5. $total = pg_num_rows($result); //mysql_num_rows() for mysql
  6.  
  7. if($total == 0)
  8. {
  9.   //code goes here.
  10. }
  11. ?>
  12.  
  13.  
  14. //array?
  15. foreach($emailarray as $email)
  16. {
  17.   if(strcasecmp($email, $otheremail) == 0)//case insensitive comparison
  18.   {
  19.     //code goes here
  20.   }
  21. }
Oct 27 '07 #3
aym
4
Expand|Select|Wrap|Line Numbers
  1. //sql?
  2. <?php
  3. $query = "select pk from tablename where email = 'emailaddress'";
  4. $result = pg_query($query); //mysql_query() for mysql
  5. $total = pg_num_rows($result); //mysql_num_rows() for mysql
  6.  
  7. if($total == 0)
  8. {
  9.   //code goes here.
  10. }
  11. ?>
  12.  
  13.  
  14. //array?
  15. foreach($emailarray as $email)
  16. {
  17.   if(strcasecmp($email, $otheremail) == 0)//case insensitive comparison
  18.   {
  19.     //code goes here
  20.   }
  21. }
the first thing that I noticed is that u forgot to put the $ sign near "where email = 'emailaddress'".
last thing is that I could not understand ur question well. Please declare more.
Oct 27 '07 #4
pbmods
5,821 Expert 4TB
Heya, runway27.

Try using the REPLACE keyword instead of INSERT.
Oct 27 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: annoyingmouse2002 | last post by:
Hi there, sorry if this a long post but I'm really just starting out. I've been using MSXML to parse an OWL but would like to use a different solution. Basically it reads the OWL (Based on XML)...
7
by: Squignibbler | last post by:
Hi all, I have a question regarding the C++ programming language regarding the nature of the relationship between pointers and arrays. If the statement MyArray is functionally identical to...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
5
by: syntax | last post by:
hi here is my test code include<stdio.h> #include<stdlib.h> int main() {
8
by: mark | last post by:
I have been modifying an application to enable debugging with Strict ON. I need to use the Array.Copy method and I have encountered an anomaly that I do not understand. I have reproduced the...
9
by: me | last post by:
Hi All, I am new to Classes and learniing the ropes with VB.NET express Here's my question - say I have a want to manage a list of books. Each book has an Author, Title and ISBN Now, I am...
14
by: John Gerrard | last post by:
Hi, my name is John and this is my first posting to comp.lang.c. I am learning C. I am a high school student with interest in programming. I have a copy of "The C programming language second...
11
by: copx | last post by:
Unforuntately, I know next to nothing about ASM and compiler construction, and while I was aware of the syntactic differences between pointers and arrays, I was not aware of this: ...
14
by: ablock | last post by:
I have an array to which i have a added a method called contains. I would like to transverse this array using for...in...I understand fully that for...in is really meant for Objects and not Arrays,...
16
by: billsahiker | last post by:
I am researching for an upcoming c# .net 2.0 project that may require reading and writing xml files. I don't want to use xmltextreader/ xmltextwriter as I prefer to have lower level file access...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.