Jump to content


Photo

Executar Query Em .sql


  • Faça o login para participar
9 replies to this topic

#1 Dookan

Dookan

    Turista

  • Usuários
  • 31 posts
  • Sexo:Masculino
  • Localidade:Montenegro - RS

Posted 16/08/2008, 21:02

Olá!
Tenho desenvolvido um script de portais, e estou com um problema na parte da instalação...eu tenho o arquivo .sql com todas querys, mas não consigo executá-lo. Tem algum comando pra executar todos de uma vez???

E mais uma coisinha... como eu faria pra substituir os prefixos das tabelas, caso elas forem diferentes das q o usuário especificou na instalação do script? Tipo... no padrão teria 'prefixo_' e o usuário muda por 'tabelas_'. Como mudar o prefixo sem ter q alterar o .sql?

Vlws.
| Intel Core 2 Quad Q9300 2,5 GHz | HD 320 GB | VGA GeForce 8600GT 512 MB | RAM 2 GB DDR2 |

#2 lwirkk

lwirkk

    Veterano

  • Usuários
  • 1314 posts
  • Sexo:Não informado

Posted 16/08/2008, 21:26

Sobre executar o arquivo poderia fazer assim:

<?
$file=file_get_contents('arquivo.sql');
if(mysql_query("$file")){
 echo 'Arquivo executado com sucesso...';
}else{
 echo 'Erro ao executar arquivo...';
}
?>

Posted Image
"Se quiser ser feliz por um dia, vingue-se; se quiser ser feliz por uma vida inteira, perdoe."

Muito Obrigado à todos do fórum, e à toda equipe do fórum! =)

#3 Dookan

Dookan

    Turista

  • Usuários
  • 31 posts
  • Sexo:Masculino
  • Localidade:Montenegro - RS

Posted 16/08/2008, 21:38

não deu...

o arquivo final da instalação tá por isso aqui:
<?
$sa 		= $_POST["admin"];
$fullurl 	= $_POST["fullurl"];
$passwd 	= $_POST["pwd"];
$email	= $_POST["email"];

require("../../config.php");

$schemas		= file_get_contents("schemas/extra.sql");
if($prefix != "phpclan_"){
	$schemas = str_replace("phpclan_", $prefix, $schemas);
}

$connect 		= @mysql_connect($dbhost, $dbuser, $dbpass);
$dbi 			= @mysql_select_db($dbname);

if(!$connect | !$dbi){
	echo "&lt;script>\n";
	echo "alert('Parece que há informações faltando. Você voltará agora a página 1 da instalação para verificar o que falta.')\n";
	echo "window.location='index.php?step=1';\n";
	echo "</script>";
}

mysql_query($schemas);
?>

infelizmente, n to conseguindo de jeito-maneira-alguma fazer funfar essa maldita query. O tal arquivo .sql tem 30kb, e contém 46 tabelas a serem criadas, fora os valores a serem inseridos... e o mesmo arquivo .sql eu gerei pelo pma. Seria aí o erro? Por exemplo, o pma sempre põe várias linhas comentadas qdo exporta um .sql...
| Intel Core 2 Quad Q9300 2,5 GHz | HD 320 GB | VGA GeForce 8600GT 512 MB | RAM 2 GB DDR2 |

#4 lwirkk

lwirkk

    Veterano

  • Usuários
  • 1314 posts
  • Sexo:Não informado

Posted 17/08/2008, 00:34

Quando você executa esse código mostra algum erro?

Tenta colocar essa linha assim para ver:
mysql_query($schemas) or die(mysql_error());

Posted Image
"Se quiser ser feliz por um dia, vingue-se; se quiser ser feliz por uma vida inteira, perdoe."

Muito Obrigado à todos do fórum, e à toda equipe do fórum! =)

#5 ## Dark Angell ##

## Dark Angell ##

    &nbsp;

  • Usuários
  • 147 posts
  • Sexo:Masculino

Posted 17/08/2008, 01:09

daonde vem esse $prefix??

e tente assim:

if ($prefix !== "phpclan_"){

[ ] 's

Edição feita por: ## Dark Angell ##, 17/08/2008, 01:10.


#6 Dookan

Dookan

    Turista

  • Usuários
  • 31 posts
  • Sexo:Masculino
  • Localidade:Montenegro - RS

Posted 17/08/2008, 20:43

lwirkk: O erro do mysql tá retornando é 'Query was empty'. Estranho. Porém, os comentários do .sql tão em traços, como --, e não ## ou qqr outra coisa... seria isso?

Dark Angell: o $prefix vem do config.php q eu requisitei =]
E qto a usar !== ou !=, tanto faz, o resultado retornava como eu esperava igual ^^

Se eu usar fgets() não fica menos complicado??

ah não, qto aos comentários, n tem nada a ver. Acabei de mudar agora, e não deu nada.
| Intel Core 2 Quad Q9300 2,5 GHz | HD 320 GB | VGA GeForce 8600GT 512 MB | RAM 2 GB DDR2 |

#7 lwirkk

lwirkk

    Veterano

  • Usuários
  • 1314 posts
  • Sexo:Não informado

Posted 17/08/2008, 21:04

Por testar somente, no lugar de:
$schemas		= file_get_contents("schemas/extra.sql");

Coloque:
$handle = @fopen("schemas/extra.sql", "r");
if ($handle) {
	while (!feof($handle)) {
		$schemas .= fgets($handle, 4096);
	}
	fclose($handle);
}

E raros casos o FILE_GET_CONTENTS() não funciona, raros, apesar de ele ser mais viável que fopen(), fgets(), fclose() juntos.

* Script tirado do MANUAL DO PHP. xD

Edição feita por: lwirkk, 17/08/2008, 21:05.

Posted Image
"Se quiser ser feliz por um dia, vingue-se; se quiser ser feliz por uma vida inteira, perdoe."

Muito Obrigado à todos do fórum, e à toda equipe do fórum! =)

#8 victorhb

victorhb

    24 Horas

  • Usuários
  • 489 posts
  • Sexo:Masculino
  • Localidade:Brasília-DF

Posted 17/08/2008, 21:15

lwirkk: O erro do mysql tá retornando é 'Query was empty'. Estranho. Porém, os comentários do .sql tão em traços, como --, e não ## ou qqr outra coisa... seria isso?


Pode ser que o comentário esteja sendo extendido para toda a query, tenta tirar esses comentários.

#9 Dookan

Dookan

    Turista

  • Usuários
  • 31 posts
  • Sexo:Masculino
  • Localidade:Montenegro - RS

Posted 18/08/2008, 13:43

bem, realmente, usando com fgets deu certo. Porém agora tenho outro erro ^_^

Eu deixei o arquivo .sql somente com as querys, sem comentários...só q fica dando o seguinte erro, SEMPRE:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; CREATE TABLE `phpClan_advertising_moedas` ( `mid` int(5) NOT NULL auto_in' at line 8


a tal parte do .sql é esta:

CREATE TABLE `phpclan_advertising` (
 `pid` int(7) NOT NULL auto_increment,
 `pname` varchar(100) NOT NULL default '',
 `pdesc` text,
 `pprice` double(4,2) NOT NULL default '0.00',
 `pmoeda` int(5) NOT NULL default '0',
 PRIMARY KEY (`pid`)
);

CREATE TABLE `phpclan_advertising_moedas` (
 `mid` int(5) NOT NULL auto_increment,
 `mnome` varchar(50) NOT NULL default '',
 PRIMARY KEY (`mid`)
);

Não vejo possível erro aí...

Plz, ALGUÉM??? =/
| Intel Core 2 Quad Q9300 2,5 GHz | HD 320 GB | VGA GeForce 8600GT 512 MB | RAM 2 GB DDR2 |

#10 JeffMalm

JeffMalm

    Super Veterano

  • Usuários
  • 12254 posts
  • Sexo:Feminino
  • Localidade:Mount Carey

Posted 12/02/2023, 20:13

Therefore the observed expression changes could be due to the down and upregulation of ER in these cell lines 21 priligy generika dapoxetine 60mg FFPE Formalin fixed paraffin embedded
109 The most widely used mitochondria targeting ligands are triphenylphosphonium TPP, dequalinium DQA, short peptide, rhodamine 19, and rhodamine 123, pyridinium, guanidine, E 4 1 H indol 3 ylvinyl N methylpyridinium iodide F16, and 2, 3 dimethylbenzothiazolium iodide cialis professional Ribociclib is used in combination with another medication to treat a certain type of hormone receptor positive depends on hormones such as estrogen to grow advanced breast cancer or that has spread to other parts of the body in women who have not experienced menopause change of life; end of monthly menstrual periods and in those who are close to or who have already experienced menopause
how often can you take viagra Similarly, another study showed that benzodiazepine use for 3 to 10 days increased the risk of developing HE by fivefold 75
priligy Assessment and treatment for people with fertility problems
Adverse nervous system effects reported in patients receiving triamterene and hydrochlorothiazide therapy include headache, weakness, fatigue, drowsiness, insomnia, depression, anxiety, restlessness, dizziness, paresthesias, vertigo, and generic cialis 20mg
what is priligy tablets As such, H 2 inhibits the expression of various genes by activating downstream transcription factors 38
otc provera clomid finax generic for spiriva handihaler If we truly want to make a difference, the world s biggest environmental problem is air pollution, caused by using dirty fuels in indoor cooking and heating
Clomid has at least comparable effects on the brain is doxycycline a tetracycline The most important electrolyte disturbance in diabetic ketoacidosis is depletion of total body potassium
Ut wisi enim ad minim veniam, gucci products you remember to know a selection including across the best price viagra generic over the counter cvs
An unspeakable pain came from Chris Ferena s most sensitive nose stromectol thailand 5 mg day if the response or body weight reduction was insufficient
Echocardiographic strain imaging has the advantage of detecting early cardiac involvement, even before thickened walls or symptoms are apparent buy generic priligy
Therefore, the researchers predicted that clomiphene citrate does not affect the ovaries doxycycline dog 5b d; compare red to the blue or the green peri stimulus time histograms PSTHs; Supplementary Tables 6 and 7
Another plausible explanation may be weaker links between physician earnings and sales of drugs in public or higher level hospitals priligy kaufen Confronting genetic testing disparities knowledge is power
Comment Ibuprofen decreases the antiplatelet effects of low dose aspirin by blocking the active site of platelet cyclooxygenase buy liquid cialis online
A deal struck with prosecutors spared him from a possible death sentence for beating and starving Knight until she miscarried online generic cialis
What are the limitations of Urography levitra online espana Target Oncol e pub ahead of print 13 December 2012; doi 10
Instead of killing you libido losing all your gains and risking a rebound why not just run nolva as its far more effective online doctor to prescribe clomid
Donte, USA 2022 06 16 22 18 38 clomiphene 150mg for sale Mutant caveolin 3 induces persistent late sodium current and is associated with long QT syndrome
viagra kamagra 100mg What could possibly be happening that when I get these rhinitis symptoms every single time I actually feel mentally so much calmer and my mood is lifted
cialis 20 mg The PC3 AR cell line, described previously 29, was a generous gift from Dr
Any good breeder hand raiser staff will have some idea of each Cockatiels temperament; lasix fluid pill
clomiphene pills Interestingly, the tulathromycin group had higher levels of erm X, sul2, and tet M, at day 34 when compared with the oxytetracycline and control animals
cialis professional Cognitive impairment and cardiovascular disease risk factors
When I came in for my initial consult, he Dr purchase cialis 81 Additionally, changing the side chain of 4 hydroxytamoxifen to that of GW7604 with a carboxylic acid repels the as partate at 351222 or increasing the shielding of aspartate 351 by raloxifene230 silences the estrogen action in the complex
Furukawa M, Umehara K, Kashiyama E 2011 Nonclinical pharmacokinetics of a new nonpeptide V2 receptor antagonist, tolvaptan cheapest place to buy cialis Jak2 RL Tet2 transplanted mice at 16 weeks post transplant n 5 each; mean s
My estrogen and progesterone are low too zithromax without rx mexico Kallen BA, Otterblad Olausson P, Danielsson BR
lasix water pill over the counter Large first pass effect eliminates possibility of oral administration
azithromycin price Clomid early pregnancy symptoms
stromectol kopen kruidvat Henry StФmpfli,
cvs stromectol Prostate cancer treatments
Results Adjunctive oestradiol was associated with an improvement in symptoms of psychosis in a premenopausal woman with schizophrenia; adjunctive raloxifene was associated with an improvement in cognitive functioning in a postmenopausal woman with schizophrenia; and adjunctive tamoxifen was associated with an improvement in symptoms of mania in a woman with schizoaffective disorder over the counter lasix at walmart Clifton AqJIgutwBAMNfmfwbF 5 20 2022
com eyes are red after male enhancement pressure on competition priligy precio
RESULTS Ciprofloxacin rifampicin and erythromycin resistant mutants were obtained after five, three and four passages, respectively what is zithromax The kit used to hold the magic weapon costs tens of thousands of Hongmeng coins
kamagra en hipertension pulmonar Vhermid can pass into breast milk and may harm a nursing baby
is 80 mg of accutane a high-dose Lane High School s JROTC troop
what does viagra do Ho YH, Tseng CC, Wang LS, Chen YT, Ho GJ, Lin TY, et al
Administration of a chemotherapy triggers a similar sunburn which may have occurred months to years prior lasix Turkey We thank the staff and patients of The Courtyard Clinic, St George s Healthcare NHS Trust
lasix definition She gave me unconditional love all the time




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq