Foros del Web » Programando para Internet » PHP »

Couldn't create new file - Check your paths and filename!

Estas en el tema de Couldn't create new file - Check your paths and filename! en el foro de PHP en Foros del Web. Hola, Ahora me aparece este error Couldn't create new file - Check your paths and filename! Cual filename????? paths es la ruta (Creo) que la ...
  #1 (permalink)  
Antiguo 17/09/2008, 14:58
 
Fecha de Ingreso: abril-2006
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Couldn't create new file - Check your paths and filename!

Hola,

Ahora me aparece este error


Couldn't create new file - Check your paths and filename!


Cual filename?????

paths es la ruta (Creo) que la tengo asi:

/home/comercio/public_html/sitemap.xml

o es asi:

/path/to/public_html/


este es el archivo.

De antemano gracias por la ayuda

<?


define ('IN_ADMIN', 1);

if (!$manual_cron || IN_ADMIN == 1)
{
include_once ('../includes/global.php');
$parent_dir = '../';
}
else
{
$parent_dir = '';
}

ini_set('max_execution_time',0); // No more timeouts
ignore_user_abort(1); // No more timeouts

include_once ($parent_dir . 'includes/class_formchecker.php');
include_once ($parent_dir . 'includes/class_custom_field.php');
include_once ($parent_dir . 'includes/class_user.php');
include_once ($parent_dir . 'includes/class_fees.php');
include_once ($parent_dir . 'includes/class_shop.php');
include_once ($parent_dir . 'includes/class_item.php');
include_once ($parent_dir . 'includes/functions_item.php');
include_once ($parent_dir . 'includes/class_messaging.php');

### Get Configuration Data

$config = $db->get_sql_row("SELECT * FROM probid_sitemap_setts WHERE id='1'");

$post = 0;
$filename = $config['filename'];
$path = $config['path'];

$xmlfile = $config['path']."/home/comercio/public_html/sitemap.xml";

if (is_file($path.$filename) AND ($post==0)) {
unlink($path.$filename);
}

$a = $db->query("SELECT * FROM probid_auctions WHERE active=1 AND approved=1 AND closed=0 AND deleted=0 ORDER BY auction_id DESC");
while ($data = $db->fetch_array($a)) {

$id = $data['auction_id'];
$link = $setts['site_path'];

$storelink = $link."shop.php?user_id=";
$auctionlink = $link."auction_details.php?auction_id=";
$classlink = $link."wanted_details.php?wanted_ad_id=";
$owner = $data['owner_id'];

$OutFile=$path.$filename;

if ($post==0) {
$output="<?xml version='1.0' encoding='UTF-8'?>\r\n<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>\r\n <url>\r\n <loc>$link</loc>\r\n <priority>0.5</priority>\r\n <changefreq>daily</changefreq>\r\n </url>\r\n";
}

if ($post==1) {
$output=" <url>\r\n <loc>$auctionlink$id</loc>\r\n <priority>0.5</priority>\r\n <changefreq>daily</changefreq>\r\n </url>\r\n";
}

$fp = fopen($OutFile, "a") or die("Couldn't create new file - Check your paths and filename!");
$numBytes = fwrite($fp, $output);
fclose($fp);
$counter = $counter + 1;
$post = 1;
}

if ($post==1) {
$query = $db->query("SELECT * FROM " . DB_PREFIX . "users WHERE shop_nb_items > '0' AND shop_active='1' AND active='1' order by username DESC");
while ($store=mysql_fetch_array($query)) {
$username = $store['user_id'];
$output=" <url>\r\n <loc>$storelink$username</loc>\r\n <priority>0.5</priority>\r\n <changefreq>daily</changefreq>\r\n </url>\r\n";

$fp = fopen($OutFile, "a") or die("Couldn't create new file - Check your paths and filename!");
$numBytes = fwrite($fp, $output);
fclose($fp);
$acounter = $acounter + 1;
$post = 1;
}
}


if ($post==1) {
$getCats = $db->query("SELECT * FROM probid_categories WHERE hidden=0 AND user_id=0 ORDER BY order_id,name");
while ($data=mysql_fetch_array($getCats)) {
$path = $setts['site_path'];
if ($data['parent_id']>0) {
$catLink=$path."categories.php?parent_id=".$data['category_id'];
} else {
$catLink=$path."categories.php?parent_id=".$data['category_id'];
}
$output=" <url>\r\n <loc>$catLink</loc>\r\n <priority>0.5</priority>\r\n <changefreq>daily</changefreq>\r\n </url>\r\n";

$fp = fopen($OutFile, "a") or die("Couldn't create new file - Check your paths and filename!");
$numBytes = fwrite($fp, $output);
fclose($fp);
$acounter = $acounter + 1;
$post = 1;
}
}

if ($post==1) {
$auctions = $db->query("SELECT * FROM probid_wanted_ads WHERE active=1 AND closed=0 AND deleted!=1 ORDER BY wanted_ad_id ASC");
while ($data=mysql_fetch_array($auctions)) {

$id = $data['wanted_ad_id'];

$output=" <url>\r\n <loc>$classlink$id</loc>\r\n <priority>0.5</priority>\r\n <changefreq>daily</changefreq>\r\n </url>\r\n";

$fp = fopen($OutFile, "a") or die("Couldn't create new file - Check your paths and filename!");
$numBytes = fwrite($fp, $output);
fclose($fp);
$bcounter = $bcounter + 1;
$post = 1;
}
}


$output = "</urlset>\r\n";
$fp = fopen($OutFile, "a") or die("Couldn't create new file - Check your paths and filename!");
$numBytes = fwrite($fp, $output);
fclose($fp);
$counter = $counter + 1;
$post = 1;

?>
  #2 (permalink)  
Antiguo 18/09/2008, 07:33
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Couldn't create new file - Check your paths and filename!

Si vas a usar un prefabricado, al menos intentá conocer cómo funciona.
Si te fijás en el código, ves esto:
Código PHP:
$fp fopen($OutFile"a") or die("Couldn't create new file - Check your paths and filename!"); 
No se pudo abrir el archivo cuyo nombre está almacenado en $OutFile.
Un par de líneas más arriba,
Código PHP:
$config $db->get_sql_row("SELECT * FROM probid_sitemap_setts WHERE id='1'");

$post 0;
$filename $config['filename'];
$path $config['path'];
...
$OutFile=$path.$filename
Sin saber lo que tenés en $config, es imposible saber cuál es el error. Probablemente no tengas permisos de escritura en la carpeta, o haya algún error en la ruta.

Mostrá el contenido de $config.


Saludos.
  #3 (permalink)  
Antiguo 18/09/2008, 08:05
 
Fecha de Ingreso: abril-2006
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Respuesta: Couldn't create new file - Check your paths and filename!

Hola,

la forma de instalcion es la siguiente:

la carpeta sitemap.xml ya tiene los permisos 777

gracias
djfritzz
-------------------------------------------------------------------------



1. Run the Following SQL query on your SQL DB:


CREATE TABLE `probid_sitemap_setts` (
`id` int(11) NOT NULL auto_increment,
`filename` varchar(100) NOT NULL default '',
`path` varchar(255) NOT NULL default '',
KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 ;

INSERT INTO `probid_sitemap_setts` VALUES (1, 'sitemap.xml', '/path/to/public_html/');



2. Upload the enclosed files to the following directories:

makesitemap.php Place it in your cron_jobs Directory.

3. Make the following file Edits as specified below:


============================================
IN FILE: admin/templates/index.tpl.php FIND:
============================================

<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td class="c1"><img src="images/a.gif" align="absmiddle"> <a href="http://www.phpprobid.com/client/support/pdesk.cgi" class="menulink" target="_blank">
<?=AMSG_SUPPORT_DESK;?>
</a></td>
</tr>
<tr>
<td class="c2"><img src="images/a.gif" align="absmiddle"> <a href="http://www.phpprobid.com/client/manuals/manual.pdf" class="menulink"target="_blank">
<?=AMSG_PPB_MANUAL;?>
</a></td>
</tr>
<tr>
<td class="c3"></td>
</tr>
</table>


======================
DIRECTLY UNDER IT ADD:
======================

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td rowspan="2"><img src="images/i_setup.gif" border="0" /></td>
<td width="100%"><img src="images/pixel.gif" height="24" width="1" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="100%" align="right" background="images/bg_part.gif"><b>Google SiteMap Modification</b></td>
<td><img src="images/end_part.gif" /></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td class="c1"><img src="images/a.gif" align="absmiddle" /> <a href="general_settings.php?page=site_map" class="menulink">Google SiteMap Modification Setup</a></td>
</tr>
<tr>
<td class="c3"></td>
</tr>
</table>


================================================== =====
IN FILE: admin/templates/general_settings.tpl.php FIND:
================================================== =====


<? } else if ($page == 'auction_images') { ?>
<!-- Images Settings BEGIN HERE -->
<tr class="c1">
<td width="150" align="right"><?=AMSG_NB_IMAGES;?></td>
<td><input name="max_images" type="text" id="max_images" value="<?=$setts_tmp['max_images'];?>" size="8" maxlength="2"></td>
</tr>


======================
DIRECTLY UNDER IT ADD:
======================


<? } else if ($page == 'site_map') { ?>
<tr class="c1">
<td width="50%" align="right">SiteMap Filename</td>
<td><input name="filename" type="text" id="filename" value="<?=$sitemap_tmp['filename'];?>" size="50" maxlength="50"></td>
</tr>
<tr class="c1">
<td width="50%" align="right">Path to SiteMap</td>
<td><input name="path" type="text" id="path" value="<?=$sitemap_tmp['path'];?>" size="50" maxlength="255"></td>
</tr>


=========================================
IN FILE: admin/general_settings.php FIND:
=========================================

case 'auction_images':
$sql_update_query = $db->query("UPDATE " . DB_PREFIX . "gen_setts SET
max_images='" . $post_details['max_images'] . "',
images_max_size='" . $post_details['images_max_size'] . "'");
break;

======================
DIRECTLY ABOVE IT ADD:
======================

case 'site_map':
$sql_update_query = $db->query("UPDATE probid_sitemap_setts SET
filename='" . $post_details['filename'] . "',
path='" . $post_details['path'] . "' WHERE id='1'");
break;

=====
FIND:
=====


$layout_tmp = $db->get_sql_row("SELECT * FROM " . DB_PREFIX . "layout_setts");


======================
DIRECTLY BELOW IT ADD:
======================

$sitemap_tmp = $db->get_sql_row("SELECT * FROM probid_sitemap_setts WHERE id='1'");

=====
FIND:
=====

$template->set('layout_tmp', $layout_tmp);

======================
DIRECTLY BELOW IT ADD:
======================

$template->set('sitemap_tmp', $sitemap_tmp);

=====
FIND:
=====

else if ($_REQUEST['page'] == 'auction_images')
{
$header_section = AMSG_GENERAL_SETTINGS;
$subpage_title = AMSG_AUCTION_IMAGES_SETTS;
}

======================
DIRECTLY BELOW IT ADD:
======================

else if ($_REQUEST['page'] == 'sitemap_mod')
{
$header_section = "General Settings";
$subpage_title = "SiteMap Modification Settings";
}



Save and upload your newly edited files. Mod installation is complete.
Make sure you upload them to their respective directories.

Your public_html DIR must have write access so it can create the sitemap.xml file!
(You can chmod it to 777 if you need to).



================================================== ==
STEP 4: CREATE YOUR ACCOUNT WITH GOOGLE SITEMAPS AT:
================================================== ==

https://www.google.com/accounts/ServiceLogin?service=sitemaps

You will need to configure setup your account with them following their process.
Once asked for the .XML file address, that would be: http://www.yoursite.com/sitemap.xml
Once its working correctly, google will come for your feed automatically each day.

==================================================
STEP 5: CREATE YOUR ACCOUNT WITH YAHOO SITEMAPS AT:
==================================================

http://siteexplorer.search.yahoo.com/mysites

You will need to configure setup your account with them following their process.
Once asked for the .XML file address, that would be: http://www.yoursite.com/sitemap.xml
Once its working correctly, you will have to manually request they come for your feed.
Yahoo does not offer an automatic daily service at this time.

STEP 6: Set a cron in your control panel to access this file 1 x per day:

http://www.yoursite.com/cron_jobs/makesitemap.php

Done!
  #4 (permalink)  
Antiguo 18/09/2008, 08:09
 
Fecha de Ingreso: abril-2006
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Respuesta: Couldn't create new file - Check your paths and filename!

Hola de nuevo,

segun tu respuesta:

Sin saber lo que tenés en $config, es imposible saber cuál es el error. Probablemente no tengas permisos de escritura en la carpeta, o haya algún error en la ruta.

Mostrá el contenido de $config.


de donde saco la informacion: Mostrá el contenido de $config.??????

Gracias
djfritzz
  #5 (permalink)  
Antiguo 18/09/2008, 08:11
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Couldn't create new file - Check your paths and filename!

Código sql:
Ver original
  1. INSERT INTO `probid_sitemap_setts` VALUES (1, 'sitemap.xml', '/path/to/public_html/');
Código php:
Ver original
  1. $config = $db->get_sql_row("SELECT * FROM probid_sitemap_setts WHERE id='1'");

Si no modificaste los valores por defecto, intentará guardar el archivo generado en
/path/to/public_html/sitemap.html

Lo cual obviamente no existe.

Tendrás que modificar la base de datos para que ese valor sea la ruta verdadera a la raíz de tu sitio. Vas a encontrar esta información en la variable $_SERVER['DOCUMENT_ROOT']


Saludos.
  #6 (permalink)  
Antiguo 18/09/2008, 15:11
 
Fecha de Ingreso: abril-2006
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Respuesta: Couldn't create new file - Check your paths and filename!

hola,

este es el admin



y esta es la consulta ce mysql

-- phpMyAdmin SQL Dump
-- version 2.11.6
-- http://www.phpmyadmin.net
--
-- Servidor: localhost
-- Tiempo de generación: 18-09-2008 a las 16:06:34
-- Versión del servidor: 5.0.51
-- Versión de PHP: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Base de datos: `comercio`
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `probid_sitemap_setts`
--

CREATE TABLE IF NOT EXISTS `probid_sitemap_setts` (
`id` int(11) NOT NULL auto_increment,
`filename` varchar(100) NOT NULL default 'default',
`path` varchar(255) NOT NULL default 'default',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Volcar la base de datos para la tabla `probid_sitemap_setts`
--

INSERT INTO `probid_sitemap_setts` (`id`, `filename`, `path`) VALUES
(1, 'sitemap.xml', '/home/www62/public_html/sitemap.xml ');

-------------------------------------------------------------------------------

e igual sigue apareciendo

Couldn't create new file - Check your paths and filename!

gracias

djfritzz
  #7 (permalink)  
Antiguo 18/09/2008, 15:12
 
Fecha de Ingreso: abril-2006
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Respuesta: Couldn't create new file - Check your paths and filename!

para ver la imagen mejor

www.pliopolio.com/imagenes/1.gif
  #8 (permalink)  
Antiguo 18/09/2008, 17:33
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Couldn't create new file - Check your paths and filename!

No era necesario que pegaras todo el código.

EL problema ahora es que, como en el campo "path" tenés

/home/www62/public_html/sitemap.xml

y en el campo "filename" tenés

sitemap.xml

El resultado será

/home/www62/public_html/sitemap.xmlsitemap.xml

Pero eso no sería problema en realidad, si no fuera porque parece que se te ha colado un espacio al final de "path", por lo que el archivo que intenta crear es

"/home/www62/public_html/sitemap.xml sitemap.xml"

Y quizás ahí está el problema.

Pero esto sería más sencillo si agregaras al principio de tu archivo php las siguientes líneas:

error_reporting(E_ALL);
ini_set('display_errors', true);

ya que te mostraría en pantalla el error real.


Saludos.
  #9 (permalink)  
Antiguo 21/09/2008, 10:03
 
Fecha de Ingreso: abril-2006
Mensajes: 12
Antigüedad: 18 años
Puntos: 0
Respuesta: Couldn't create new file - Check your paths and filename!

Hola,

hice lo que me aconsejaste, y ahora me da estos errores los cuales los he tratado de corregir pero no he podido, de antemano gracias por la ayuda.

------------------------------------------------------------------------------------------------------
Notice: Undefined variable: manual_cron in /home/comercio/public_html/cron_jobs/makesitemap.php on line 13


<?

error_reporting(E_ALL);
ini_set('display_errors', true);

define ('IN_ADMIN', 1);

if (!$manual_cron || IN_ADMIN == 1)
{
include_once ('../includes/global.php');
$parent_dir = '../';
}
else
{
$parent_dir = '';


------------------------------------------------------------------------------------------------------


Notice: Undefined index: rewrite_params in /home/comercio/public_html/includes/init.php on line 56


if ($setts['is_mod_rewrite'])
{
$valsArray = explode(",", $_REQUEST['rewrite_params']); $valsCnt = 0;
$count_valsArray = count($valsArray);
while ($valsCnt < $count_valsArray)
{
$_REQUEST[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
$_GET[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
$_POST[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
$valsCnt += 2;
}

----------------------------------------------------------------------------------------------------

Notice: Undefined offset: 1 in /home/comercio/public_html/includes/init.php on line 61

{
$_REQUEST[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt]; $_GET[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
$_POST[$valsArray[$valsCnt + 1]] = $valsArray[$valsCnt];
$valsCnt += 2;
}

------------------------------------------------------------------------------------------------------

Notice: Undefined index: start in /home/comercio/public_html/includes/init.php on line 108

if (!eregi("swap_offer.php", $_SERVER['PHP_SELF']))
{
$session->unregister("swap_offer_id");
}
if (!eregi("makesitemap.php", $_SERVER['PHP_SELF']))
{
$session->unregister("makesitemap.php");
}
$start = abs(intval($_GET['start']));
?>

--------------------------------------------------------------------------------------------------------
Notice: Undefined index: probid_is_seller in /home/comercio/public_html/includes/class_session.php on line 36


Notice: Undefined index: probid_user_id in /home/comercio/public_html/includes/class_session.php on line 36



class session
{

var $vars = array (NULL);

function set($variable, $value)
{
$_SESSION[SESSION_PREFIX.$variable] = $value;
$this->vars[$variable] = $value;
}

function unregister($variable)
{
if (isset($_SESSION[SESSION_PREFIX.$variable]))
{
unset($_SESSION[SESSION_PREFIX.$variable]);
$this->vars[$variable] = NULL;
}
}

function destroy()
{
session_destroy();
}

function value($variable)
{
return $_SESSION[SESSION_PREFIX.$variable];
}

function is_set($variable)
{
return (!empty($_SESSION[SESSION_PREFIX.$variable])) ? TRUE : FALSE;
}

}
?>

----------------------------------------------------------------------------------------------------

Warning: fopen(/home/www62/public_html/sitemap.xml) [function.fopen]: failed to open stream: No such file or directory in /home/comercio/public_html/cron_jobs/makesitemap.php on line 70
Couldn't create new file - Check your paths and filename!


$fp = fopen($OutFile, "a") or die("Couldn't create new file - Check your paths and filename!");
$numBytes = fwrite($fp, $output);
fclose($fp);
$counter = $counter + 1;
$post = 1;

------------------------------------------------------------------------------------------------
  #10 (permalink)  
Antiguo 21/09/2008, 13:56
AlvaroG
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Couldn't create new file - Check your paths and filename!

Casi todos los errores son problemas de variables no definidas. Si no sabés cómo arreglarlos, simplemente quitá las líneas que te recomendé agregar y olvidate del tema.

Ahora, el último error es el interesante.
Por lo visto está tomando la ruta correcta, pero aún así no puede crear el archivo. Mejor dicho, ni siquiera lo intenta. Cuando le pasás el modo "a" a fopen(), el manual dice que "si el archivo no existe, intenta crearlo". Obviamente en este caso no lo puede crear, y me parece que el problema es de permisos. Seguramente PHP / Apache no tienen permisos para crear el archivo.

Hay una forma muy sencilla de comprobarlo: creá un archivo sitemap.xml vacío, y colocalo en la misma ruta donde el programa intenta guardar (/home/www62/public_html). Luego, con tu cliente FTP favorito, le cambiás los permisos a 777 (o "lectura y escritura para todo el mundo").
Ejecutá de nuevo el programa PHP, ya debería funcionar.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:58.