Клубове Дир.бг
powered by diri.bg
търси в Клубове diri.bg Разширено търсене

Вход
Име
Парола

Клубове
Dir.bg
Взаимопомощ
Горещи теми
Компютри и Интернет
Контакти
Култура и изкуство
Мнения
Наука
Политика, Свят
Спорт
Техника
Градове
Религия и мистика
Фен клубове
Хоби, Развлечения
Общества
Я, архивите са живи
Клубове Дирене Регистрация Кой е тук Въпроси Списък Купувам / Продавам 05:47 28.09.24 
Клубове/ Компютри и Интернет / Бази данни Всички теми Следваща тема Пълен преглед*
Информация за клуба
Тема mySQL Проблем!
АвторDolorian (Нерегистриран) 
Публикувано12.03.04 17:41  



Поздрави на всички !
Начинаещ съм в mySQL и имам малък проблем, за който се надявам на помощ от по-компетентните в тази област. Ползвам WinXP/Apache 2.048/ PHP 4.3.4/ mySQL 4.17/ MySQLCC 0.94 .Апачето и пхп работят без грешка. Когато стартирам следния скрипт:

<?
/************************************************************
this script runs only once, it then drops the database before
mysql connection is closed.
************************************************************/

/***************************************************
string values passed on to the following 5 variables.
two of each are assigned to 'ice' and the rest three
tag along into 'mysql_connect'
***************************************************/
$iceCreamOne = "Vanilla"; // Type One Ice Cream
$iceCreamTwo = "Cookie Dough Ice Cream"; // Type Two Ice Cream
$host = "localhost"; // hostname...in our case localhost
$username = "root"; // root is our default
$password = "820721"; // your mysql password please

//open connection to the MySQL database server.
$connection = mysql_connect($host,$username,$password);
//if connection fails, display the error involved
if ($connection == false){
echo mysql_errno().": ".mysql_error()."<BR>";
//echo("Your username or password is not correct.");
exit;
}

/************************************************
After supper we will have two kinds of desserts
create the database then select it. Two functions
called mysql_create_db() & mysql_select_db()
if statements to check success of create & select
************************************************/
$create_success = mysql_create_db("aftersupper");
if($create_success)echo("<b><font color=\"blue\">create database: success!</font></b>
");
$select_success = mysql_select_db("aftersupper");
if($select_success)echo("<b><font color=\"blue\">selected the created database: success!</font></b>");

/*************************************************************
your choice for 2 desserts
for me I like vanilla[iceCreamOne] & cookie dough[iceCreamTwo]
*************************************************************/
mysql_query("CREATE TABLE desserts(iceCreamOne VARCHAR(25),
iceCreamTwo VARCHAR(25))");

/*******************************************************************************
i put my two favorite icecream types into table desserts: vanilla & cookie dough
remember im using variables that have been assigned with strings up there ^^^.
*******************************************************************************/
mysql_query ("INSERT INTO desserts (iceCreamOne, iceCreamTwo) VALUES
('$iceCreamOne', '$iceCreamTwo')");

/*******************************************************************************
as long as there is information in the table keep printing.
i have two values in table 'desserts', both rows are passed to variable 'result'
*******************************************************************************/
$result = mysql_query ("SELECT * FROM desserts");

//checking to see that select was successfull
//if ($result){echo "<h2>Successfully selected from table desserts!</h2>\n";}

//assign the number of rows from variable $result to $numOfRows
//$numOfRows = mysql_num_rows ($result);

//for ($i = 0; $i < $numOfRows; $i++)
//{
$row = mysql_fetch_array($result);
print ("<h3>My 2 most favorite Ice Cream are:</h3>
\n");
print($row["iceCreamOne"]." and ");
print($row["iceCreamTwo"]. "
");
// }

//Database gets dropped. You can comment the line below if you wish to keep the database
mysql_query("DROP DATABASE aftersupper");

//close the connection to the db with the particular user :: $username
mysql_close();
?>

Получавам следната грешка:
Notice: mysql_create_db(): This function is deprecated, please use mysql_query() to issue a SQL CREATE DATABASE statement instead. in C:\Apache2\htdocs\test2.php on line 33

След като заменя в кода ф-та mysql_create_db() с mysql_query() нищо не тръгва и изкарва:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache2\htdocs\test2.php on line 66

Ако някой знае къде е грешката моля да ми помогне. Мерси Предварително.



Цялата тема
ТемаАвторПубликувано
* mySQL Проблем! Dolorian   12.03.04 17:41
. * Re: mySQL Проблем! nupaT   12.03.04 19:23
. * Re: mySQL Проблем! Dolorian   12.03.04 19:51
Клуб :  


Clubs.dir.bg е форум за дискусии. Dir.bg не носи отговорност за съдържанието и достоверността на публикуваните в дискусиите материали.

Никаква част от съдържанието на тази страница не може да бъде репродуцирана, записвана или предавана под каквато и да е форма или по какъвто и да е повод без писменото съгласие на Dir.bg
За Забележки, коментари и предложения ползвайте формата за Обратна връзка | Мобилна версия | Потребителско споразумение
© 2006-2024 Dir.bg Всички права запазени.