Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia a todos.
Galera, não "manjo" nada em PHP e estou com os seguintes erros em minha página:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/storage/b/58/d2/arterz1/public_html/index.php on line 9
Warning: extract() [function.extract]: First argument should be an array in /home/storage/b/58/d2/arterz1/public_html/index.php on line 10
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/storage/b/58/d2/arterz1/public_html/index.php on line 14
Warning: extract() [function.extract]: First argument should be an array in /home/storage/b/58/d2/arterz1/public_html/index.php on line 15
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/storage/b/58/d2/arterz1/public_html/index.php on line 25
Warning: extract() [function.extract]: First argument should be an array in /home/storage/b/58/d2/arterz1/public_html/index.php on line 26
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/storage/b/58/d2/arterz1/public_html/index.php on line 43
Warning: extract() [function.extract]: First argument should be an array in /home/storage/b/58/d2/arterz1/public_html/index.php on line 44
Esse é meu código:
::<?php
require_once("./bluadmin/flash/databaseinfo.php");
include('./bluadmin/browserdetect.php');
$dir = './v1site_images/';
$query = "SELECT MetaTitle, MetaKey, MetaDescription FROM v1Settings";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
extract($row);
$query = "SELECT MetaStats FROM Settings";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
extract($row);
$bgColor = "000000";
$txtColor = "FFFFFF";
$accentColor = "FFFFFF";
$frameColor = "666666";
$query2 = "SELECT * FROM Splash";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_array($result2, MYSQL_BOTH);
extract($row2);
$bgColor = $row2["BackColor"];
$txtColor = $row2["TextColor"];
$accentColor = $row2["AccentColor"];
$frameColor = $row2["FrameColor"];
for ($i=1; $i<=4; $i++){
if ($row2["URL".$i] == "index2.php"){
$new_url = "index2.php?v=v1";
$query3 = "update Splash set URL".$i." = '$new_url'";
$result3 = mysql_query($query3);
}
}
$query2 = "SELECT * FROM Splash";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_array($result2, MYSQL_BOTH);
extract($row2);
$TextFont = "Arial, Helvetica, sans-serif";
?>
Alguém pode me ajudar ??
Alterei todas as linhas, agora da erro nessas linhas(11, 17, 28 e 46):
extract($row);
Faça assim amigo
if ($row) extract($row);
Leia o link abaixo com carinho antes de prosseguir com o desenvolvimento.
Abraços.
rsrs, obrigado pela dica d manual, mas acho que agora é muita informação pra eu ler, mas vou fazer um esforço.
Bom, agora nnao aparece nada, a página fica toda preta e nnao tem nenhuma msg de erro!
resumido.. troca os:
mysql_query($query);
por:
mysql_query($query)or die( mysql_error() );
leia:
http://forum.imasters.com.br/index.php?/topic/375800-orientacoes-para-uma-boa-participacao/
Refiz as alterações e apareceu o seguinte erro:
::Table 'arterz12.v1Settings' doesn't exist
pronto, tá ai o erro.
a tabela v1Settings, não existe no banco de dados arterz12
confira se o nome é esse mesmo, o TaMaNHo dA CaIXa é importante, verifique.
Então, mas não tenho nada nessa tabela, não preciso dela pra nada !
Eu estava fazendo um teste e criei essa tabela, mas não tem nenhuma informação nela.
Na verdade não tem nem tabela, só tem esse banco criado com o nome de 'arterz12'.
então é impossível você fazer uma query numa tabela que não existe
e aqui você tenta isso:
$query = "SELECT MetaTitle, MetaKey, MetaDescription FROM v1Settings";
Eu tinha essa tabela nesse banco, mas acabei exluindo, vou ter que entrar em contato com o desenvolvedor para ele colocar novamente essa tabela onde está hospedado o site.
Mesmos assim obriagdo a todos pela ajuda.
se não tinha dado nenhum, e você acha que essa tabela não servia pra nada, apenas comente o trecho que tenta usar ela:
/*
$query = "SELECT MetaTitle, MetaKey, MetaDescription FROM v1Settings";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
extract($row);faça o mesmo procedimento de habilitar os erros, e o mysql_error() nas outras querys, para ver se fica tudo Okay agora.
Olá pessoal!
Minha postagem não é bem uma resposta, mas a busca da solução de um problema idêntico, mas em um sistema diferente.
O erro reportado é este:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/html/cavidsistemas.com.br/web/cavid/news/database/mysql.php on line 98
O Código é este:
<?php
/ autor: Rafael Clares <rafadinix@gmail.com> /
Class mysql
{
public $query;
public $data;
public $result;
public $rows;
public $page = 0;
public $perpage = 10;
public $current = 1;
public $url;
public $link = '';
public $total = '';
public $pagination = false;
protected $config;
protected $host;
protected $port;
protected $user;
protected $pass;
protected $dbname;
protected $con;
public function __construct()
{
try
{
#array com dados do banco
include 'database.conf.php';
global $databases;
$this->config = $databases['local'];
# Recupera os dados de conexao do config
$this->dbname = $this->config['dbname'];
$this->host = $this->config['host'];
$this->port = $this->config['port'];
$this->user = $this->config['user'];
$this->pass = $this->config['password'];
# instancia e retorna objeto
$this->con = mysql_connect( "$this->host", "$this->user", "$this->pass" );
mysql_select_db( "$this->dbname" );
if ( !$this->con )
{
throw new Exception( "Falha na conexão MySql com o banco [$this->dbname] em database.conf.php" );
}
else
{
return $this->con;
}
$this->url = $_SERVER['SCRIPT_NAME'];
}
catch ( Exception $e )
{
echo $e->getMessage();
exit;
}
return $this;
}
public function query( $query = '' )
{
try
{
if ( $query == '' )
{
throw new Exception( 'mysql query: A query deve ser informada como parâmetro do método.' );
}
else
{
$this->query = $query;
if($this->pagination == true){
$this->result = mysql_query( $this->query );
$this->fetchAll();
$this->paginateLink();
$this->query .= " LIMIT $this->page, $this->perpage";
$this->pagination = false;
}
$this->result = mysql_query( $this->query );
}
}
catch ( Exception $e )
{
echo $e->getMessage();
exit;
}
return $this;
}
public function fetchAll()
{
$this->data = "";
$this->rows = 0;
while ( $row = mysql_fetch_array( $this->result, MYSQL_ASSOC ) )
{
$this->data[] = $row;
}
if ( isset( $this->data[0] ) )
{
$this->rows = count( $this->data );
}
return $this->data;
}
public function rowCount()
{
return @mysql_affected_rows();
}
public function getUrl($perpage)
{
$this->url = $_SERVER['REQUEST_URI'];
return $this;
}
public function paginate($perpage)
{
$this->pagination = true;
$this->perpage = $perpage;
return $this;
}
public function paginateLink()
{
if(!preg_match('/\?/',$this->url))
{
$this->url .= "?";
}else{
$this->url .= "&";
}
if ( isset( $_GET['page'] ) )
{
$this->current = $_GET['page'];
$this->page = $this->perpage * $_GET['page'] - $this->perpage;
if ( $_GET['page'] == 1 )
{
$this->page = 0;
}
}
$this->total = $this->rows;
if ( $this->rows > $this->perpage )
{
$this->link = "<div class=\"pagination\"><ul>";
$prox = "javascript:;";
$ant = "javascript:;";
if ( $this->current >= 2 )
{
$ant = $this->url."page=" . ($this->current - 1);
}
if ( $this->current >= 1 && $this->current < ($this->total / $this->perpage))
{
$prox = $this->url."page=" . ($this->current + 1);
}
$this->link .= '<li><a href="' . $ant . '">«</a></li>';
$from = round( $this->total / $this->perpage );
if($from == 1){$from++;}
for ( $i = 1; $i <= $from ; $i++ )
{
if ( $this->current == $i )
{
$this->link .= "<li class=\"active\"><a>$i</a></li>\n";
}$this->link .= "<li><a href=\"".$this->url."page=$i\">$i</a></li>\n";
}
}
$this->link .= '<li><a href="' . $prox . '">»</a></li>';
$this->link .= "</ul>\n";
$this->link .= "</div>\n";
}
return $this;
}
public function cut($str,$chars,$info= '')
{
if ( strlen( $str ) >= $chars )
{
$str = preg_replace( '/\s\s+/', ' ', $str );
$str = strip_tags( $str );
$str = preg_replace( '/\s\s+/', ' ', $str );
$str = substr( $str, 0, $chars );
$str = preg_replace( '/\s\s+/', ' ', $str );
$arr = explode( ' ', $str );
array_pop( $arr );
//$arr = preg_replace('/\ /i',' ',$arr);
$final = implode( ' ', $arr ) . $info;
}
else
{
$final = $str;
}
return $final;
}
}
/ end file /
Desde já agradeço a Todos, abraço.
O erro esta ocorrendo nesta linha.
$row = mysql_fetch_array($result);
Tenta trocar todas as ocorrencias por.