PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.php > php/mysql - how to see if they can connect?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
php/mysql - how to see if they can connect?

Réponse
 
LinkBack Outils de la discussion
Vieux 17/10/2007, 22h16   #1
David
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut php/mysql - how to see if they can connect?

I have installed php and mysql but i am not sure the 2 are able to talk to
each other.

i have created a database in mysql called test / user: test / pw: test and
given the user select privelges.

the table has one field column called test.

Can anyone tell me a simple php script to try to see if a connection can be
made and display that table column??



  Réponse avec citation
Vieux 18/10/2007, 04h03   #2
Kim André Akerø
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: php/mysql - how to see if they can connect?

David wrote:

> I have installed php and mysql but i am not sure the 2 are able to
> talk to each other.
>
> i have created a database in mysql called test / user: test / pw:
> test and given the user select privelges.
>
> the table has one field column called test.
>
> Can anyone tell me a simple php script to try to see if a connection
> can be made and display that table column??


Simple sample script:

<?php
$db = mysql_connect("localhost", "test", "test");
if ($db !== false) {
echo "could not connect: ".mysql_error();
exit;
}
if (!mysql_select_db("test")) {
echo "problem selecting the database: ".mysql_error();
exit;
}
$testsel = mysql_query("SELECT * FROM `test`");
if ($testsel !== false) {
echo "it works!";
}
else {
echo "query error: ".mysql_error();
}
?>

If there's an error, it will be output to the browser (or wherever
you're running the script from). The resulting error message (if any)
might also tell you what the problem is.

--
Kim André Akerø
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 06h19.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,06795 seconds with 10 queries