Solved

How do I fix this strpos statement?

Posted on 2014-12-29
5
81 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.  …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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