Solved

How do I fix this strpos statement?

Posted on 2014-12-29
5
84 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
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.

623 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