Solved

PHP Echo array question

Posted on 2014-11-07
5
104 Views
Last Modified: 2014-11-16
Having a hard time to echo $agentsStuff within this line of code:

schema (echo $agentsStuff[bizID]1,10);

Open in new window

0
Comment
Question by:seopti
  • 3
  • 2
5 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40429212
Please run this PHP instruction and post the output here, thanks.

<?php var_dump($agentsStuff);

Open in new window

0
 

Author Comment

by:seopti
ID: 40429264
I have a bizID for each business in the database which I can echo with:

<?php echo $agentsStuff['bizID'];?>

Now I've installed an addon which adds schema org. It is printed this way:

<?php schema('someItemID');      //print schema.org rich snippets  ?>

What I would like to do is to echo the bizID as someItemID. I tried this for a few hours without success.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40429527
I tried this for a few hours without success.
Don't waste your time like that.  Just work with me.

Please run this PHP instruction and post the output here, thanks.

<?php var_dump($agentsStuff);

Open in new window

0
 

Author Comment

by:seopti
ID: 40430390
When I do var_dump  on $agentsStuff I get:

array(30) { [0]=> string(6) "624082" ["bizID"]=> string(6) "624082" [1]=> string(9) "Attorneys" ["bizCatSub"]=> string(9) "Attorneys" [2]=>  .....

And there is the bizID which I need echoed as someItemID.
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40430449
It looks like you've got a results set from a query, and you've used MySQL_Fetch_Array() to retrieve the data.  That's an AntiPractice (see number 27 for an explanation of why you want to change that).

To get a different column name in the results set, and therefore a different key in the array, you can change your query to use the AS clause in the SELECT query.  Example:

SELECT bizID AS someItemID FROM myTable...

I don't understand part of this question about this line of code:
schema (echo $agentsStuff[bizID]1,10);

Open in new window

What is schema()?  Is it some kind of locally defined function?  What does "1,10" mean in this context?
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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 dynamically set the form action using jQuery.

759 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

20 Experts available now in Live!

Get 1:1 Help Now