Jump to content

Shopping cart function.file-get-contents]: failed to open stream


juandamz

Recommended Posts

hello, im Juan Mora, i bought your "Shopping Cart" video tutorial yesterday, i followed each step and it work perfectly.

i never did some of the last steps because this web page, is for a competition at my school, and it doesn't have to work all the way, by the way this is the first time i work with php.

so when i finally got what i wanted for my web page, i went ahead and uploaded on my host "lithium hosting", first the index.php file couldnt find the functions.php, so what i had to do, was to put all the files in the same folder, and it work but now it just displays this:

Warning: file_get_contents(catalog.xml) [function.file-get-contents]: failed to open stream: No such file or directory in/home/jdportfo/public_html/alonso/functions.php on line 11

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/jdportfo/public_html/alonso/functions.php:11 Stack trace: #0 /home/jdportfo/public_html/alonso/functions.php(11): SimpleXMLElement->__construct('') #1 /home/jdportfo/public_html/alonso/templates.php(36): get_xml_catalog() #2 /home/jdportfo/public_html/alonso/index.php(16): render_products_from_xml() #3 {main} thrown in/home/jdportfo/public_html/alonso/functions.php on line 11

 

the project its for tomorrow and i would appreciated if you guys can help me

 

here's the web page "http://alonso.jdportfolio.com"

Link to comment
Share on other sites

Warning: file_get_contents(catalog.xml) [function.file-get-contents]: failed to open stream: No such file or directory in/home/jdportfo/public_html/alonso/functions.php on line 11

 

The error message is hinting at what you need to do; PHP can't find the file:

 

'No such file or directory ...'

 

So take a look at where PHP thinks the file should be, and put the file PHP is looking for there. Does that make sense?

 

Stefan

Link to comment
Share on other sites

it does make sense, and that's what i tried at first but it didnt work...

here's what i did

 

first i put all the files in the same folder and them this

 

functions.php

 

define('STORE_XML' , 'Catalog.xml');


/** FUNCTIONS */

function get_xml_catalog()
{
return  new SimpleXMLElement(file_get_contents('catalog.xml'));
}

Link to comment
Share on other sites

OHH i got it , the Catalog.xml on the first line is capitalize and the catalog.xml on the "return" line is not

define('STORE_XML' , 'Catalog.xml');


/** FUNCTIONS */

function get_xml_catalog()
{
return  new SimpleXMLElement(file_get_contents('catalog.xml'));
}

 

i make them both capitalize and it work

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...