Solved

How do I fix this strpos statement?

Posted on 2014-12-29
5
82 Views
Last Modified: 2014-12-29
How to I fix this strpos statement?  I attempted to have it pregmatch 'GTIN' within the string and could not get that to work correctly, and now I am attempting t use the entire line of text....

I am getting the following error:  
Parse error: syntax error, unexpected '') {' (T_CONSTANT_ENCAPSED_STRING)

if (strpos('"Invalid GTIN value"|"Insufficient product identifiers: Missing GTIN attribute."',$row13['errordesc']')  {
        $upc="";
        } else {
        $upc="$row13['upc']";
        }

Open in new window

0
Comment
Question by:lawrence_dev
  • 2
  • 2
5 Comments
 
LVL 58

Assisted Solution

by:Gary
Gary earned 200 total points
ID: 40522747
if (strpos('"Invalid GTIN value"|"Insufficient product identifiers: Missing GTIN attribute."',$row13['errordesc'])!==false)  {
        $upc="";
        } else {
        $upc="$row13['upc']";
        }

Open in new window

0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 300 total points
ID: 40522749
Try this:
if (strpos("Invalid GTIN value"|"Insufficient product identifiers: Missing GTIN attribute.", $row13["errordesc"]))
				{
        $upc="";
        } else {
        $upc= $row13['upc'];
        }

Open in new window

0
 

Author Comment

by:lawrence_dev
ID: 40522971
Gary,
I got an error on yours but I appreciate your consistent help very much!!!
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

Marco,
Yours worked great!  Thanks!
0
 

Author Closing Comment

by:lawrence_dev
ID: 40522972
Thanks!!
0
 
LVL 58

Expert Comment

by:Gary
ID: 40523066
Yeah I missed this as well which Marco corrected

$upc="$row13['upc']";
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What's wrong with this PDO query? 5 28
Redirect 301 from one address  to another 5 26
Link failure 16 35
How do I show metrics with PHP or Javascript 6 34
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question