Solved

How do I fix this strpos statement?

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now