connection to sql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leen
    New Member
    • Aug 2010
    • 22

    connection to sql

    i want connect to sql
    this is my page "MySqlConnectio n.php":
    Code:
    <?php 
    	$cite_school=mysql_connec("localhost","****","****");
    	$cite_bdd=mysql_select_db("ecole");
    	if(!$cite_school||!$cite_bdd)
    	{
    		die("Connexion impossible à la base de données". mysql_error());
    	}
    ?>
    what is the problem?
    Last edited by Dormilich; Aug 25 '10, 09:11 AM. Reason: Please use [code] tags when posting code
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    Hi Leen,
    Please use [code] tags around your code for the future, and also include any error messages you receive which makes us finding the problem quicker.
    The biggest problem I see that will stop this from working is you misspelling: "mysql_connect" . You have "mysql_conn ec".

    Comment

    • Leen
      New Member
      • Aug 2010
      • 22

      #3
      oh sorry here I Write like this ,into my code I write 'mysql_connect ".
      when I open this page nothing happens, but in the other pages as a "sign up" in which includ the page "MySQLConne ct", I get "connection diagnostic problems", ie it does not make a connection tothe data base "school".
      I know this is the easiest page in my project, but I can not detect the problem has

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Try run this, and post exactly what is returned:
        Code:
        mysql_connect('localhost', '****', '****') or die("Could not connect: ".mysql_error());
        mysql_select_db('ecole') or die("Could not select ecole: ".mysql_error());

        Comment

        • Leen
          New Member
          • Aug 2010
          • 22

          #5
          i try it.
          when i open this page in "internet explorer", i get blanc page.
          does that mean that there is connection to database??

          Comment

          • TheServant
            Recognized Expert Top Contributor
            • Feb 2008
            • 1168

            #6
            Try adding:
            Code:
            error_reporting(E_ALL);
            ini_set('display_errors', 'on');
            To the top of your page. Tell us what is says after that.

            Comment

            • Leen
              New Member
              • Aug 2010
              • 22

              #7
              also i get blanc page

              Comment

              • TheServant
                Recognized Expert Top Contributor
                • Feb 2008
                • 1168

                #8
                Sorry, I should have made this clearer.
                Put in a page:
                Code:
                error_reporting(E_ALL);
                ini_set('display_errors', 'on');
                mysql_connect('localhost', '****', '****') or die("Could not connect: ".mysql_error());
                mysql_select_db('ecole') or die("Could not select ecole: ".mysql_error());
                If that's what you did, then I think there is something wrong with your PHP install. You haven't had any other issues with PHP functions? What PHP version are you running?

                Comment

                • Leen
                  New Member
                  • Aug 2010
                  • 22

                  #9
                  i try it but also i get white page.
                  i used easy php, but he doesn't work in windows seven, now i use wamp
                  thank u verry much for ur help.

                  Comment

                  • Atli
                    Recognized Expert Expert
                    • Nov 2006
                    • 5062

                    #10
                    Put this into a new PHP file and run it. It should tell you exactly what is going on. If it returns a blank page, there is something wrong with the server; something you won't be able to fix in your code. You'd have to reconfigure/reinstall the server software.
                    [code=php]<?php
                    // Enable error reporting
                    ini_set('displa y_errors', true);
                    error_reporting (E_ALL + E_NOTICE);

                    // Make sure the mysql extension is available
                    if(!function_ex ists("mysql_con nect")) {
                    die("MySQL extension not available.");
                    }

                    // Try to connect
                    if(!($dbLink = mysql_connect(" localhost", "usr", "pwd"))) {
                    die("failed to connect to MySQL: " . mysql_error());
                    }
                    if(!mysql_selec t_db("ecole", $dbLink)) {
                    die("Failed to select db: " . mysql_error());
                    }

                    // It worked!
                    echo "Success! You can connect to your MySQL database without problems.";
                    ?>[/code]

                    Comment

                    • Leen
                      New Member
                      • Aug 2010
                      • 22

                      #11
                      thank u verry much

                      Comment

                      • Leen
                        New Member
                        • Aug 2010
                        • 22

                        #12
                        thank u
                        it return:Success! You can connect to your MySQL database without problems
                        that mean it's true. thank u.
                        but when i run the page SignUp.php, i get:'internet explorer cannot display the webpage'

                        this is the page SignUp.html:
                        Code:
                        <html>
                        <form method="post" action="SignUp.php">
                        <body>
                        <div align=center>
                        <table  cellspacing=15>
                        <caption><h1>SignUp</h1></caption>
                        <tr>
                               <td class=F>last name</F></td>
                               <td colspan="3" width=150><input type=text  name="nom" >
                        	   <td class=F>first  name</td>
                               <td colspan="3"><input type=text  name="prenom"></td>
                        </tr>
                        <tr>
                        	   <td class=F>father name</td>
                               <td colspan="3"><input type=text name="perenom"></td>
                        	   <td class=F>date of birth</td>
                               <td colspan="3" ><input type=text name="dob"></td>
                        </tr>
                        <tr>
                               <td class=F>telephone</td>
                               <td colspan="3"><input type=text name="phone"></td>
                        	   <td class=F>email</td>
                               <td colspan="3"><input type=text name="mail"></td>
                        </tr>
                        <tr>
                               <td class=F>country</td>
                               <td colspan="3"><input type=text name="ville"></td>
                        	   <td class=F>rue</td>
                               <td colspan="3"><input type=text name="rue"></td>
                        </tr>
                        <tr>
                               <td class=F>immeuble</td>
                               <td colspan="3"><input type=text name="immeuble"></td>
                        </tr>
                        <tr>
                               <td class=F>identity card</td>
                               <td colspan="3"><input type=file name="idcard"></td>
                        	   <td class=F>papaer of success</td>
                               <td colspan="3"><input type=file name="pps"></td>
                        </tr>
                        <tr>
                               <td class=F>user name</td>
                               <td colspan="3"><input type=text name="userNom"></td>
                        </tr>
                        <tr>
                               <td class=F>password</td>
                               <td colspan="3"><input type=password name="pass"></td>
                        	   <td class=F>confirm password</td>
                               <td colspan="3"><input type=password name="pass"></td>
                        
                               <td colspan="2"><input type="submit" name="submit" width="70%" height="40%"></td>
                        	   <td><input type="reset" name="submit" value="Clear" width="100%" height="50%"></td>
                        </tr>
                        </table>
                        
                        </body>
                        </form>
                        </html>
                        and this is SignUp.php:
                        Code:
                        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                        <?php
                        SESSION_start();
                        $nom=$_POST['nom'];
                        $prenom=$_POST["prenom"];
                        $perenom=$_POST["perenom"];
                        $dob=$_POST["dob"];
                        $phone=$_POST["phone"];
                        $mail=$_POST["mail"];
                        $ville=$_POST["ville"];
                        $rue=$_POST["rue"];
                        $immeuble=$_POST["immeuble"];
                        $idcard=$_POST["idcard"];
                        $pps=$_POST["pps"];
                        $userNom=$_POST["userNom"];
                        $pass=$_POST["pass"];
                        include("essai.php");
                        $insert="INSRET INTO 'etudiante'
                        VALUES('',$nom,
                         '$prename', '$perenom', '$dob', '$phone', '$mail', '$ville', '$rue', '$immeuble', '$idcaed', '$pps','$userNom', MD5('$pass'))";
                         $result= mysql_query($insert);
                         if($result)
                         {
                         	header("Location:Acceptance.php");
                         }
                         else
                         {
                         	echo("You have missing or wrong input infomation". mysql_error());
                         }
                         mysql_close();
                         ?>
                         </html>
                        i name the page u gave me 'essai.page'
                        but why when i press the button 'submit', i get 'internet explorer cannot display the webpge'???

                        Comment

                        • Atli
                          Recognized Expert Expert
                          • Nov 2006
                          • 5062

                          #13
                          Ok, first of all let me say that Internet Explorer is a horrible browser, especially for web development. It's usually best to use Firefox or Chrome, and then just check in with IE from time to time to see if you need to apply fixes. Join the 21'st century! ;)

                          Now, with that out of the way...
                          Leen: but when i run the page SignUp.php, i get:'internet explorer cannot display the webpage'
                          This would indicate a problem with the connection to your page, not the page itself. What *exactly* does the URL of the page that generates this error look like? Be sure to note the case of the file name. ("SignUp.php " is not equal to "signup.php ".)

                          Also, even though this is probably not a part of the current problem, in your SignUp.php code, you start of by putting in the HTML doctype but then go on to use the header() function later on. You can not do that.

                          The header function must be used before ANY content is "sent" to the browser. In a HTTP response the headers are sent first, and then the content. Once you start sending HTML, then the headers are locked. Even a white-space before the <?php tag of a PHP page will trigger this lock-down of the headers.

                          Comment

                          • Leen
                            New Member
                            • Aug 2010
                            • 22

                            #14
                            now i use firefox.
                            yes, signup is different to SignUp.
                            but now i get:
                            "
                            The connection was reset
                            The connection to the server was reset while the page was loading.
                            * The site could be temporarily unavailable or too busy. Try again in a few
                            moments.
                            * If you are unable to load any pages, check your computer's network
                            connection.
                            * If your computer or network is protected by a firewall or proxy, make sure
                            that Firefox is permitted to access the Web.
                            "
                            why??? always wrong? why?

                            Comment

                            • Leen
                              New Member
                              • Aug 2010
                              • 22

                              #15
                              this is my new page
                              i have join the 2 pages in one, but also false...why?
                              Code:
                              <?php
                              	include("entete.html");
                              ?>
                              <html>
                              <form method="post">
                              <head>
                              	<title>Sign Up</title>
                              	<Style type="text/css">
                              	.text {width:785px;}
                              	.F { font-family: "Verdana"; font-size: 20px; text-transform: "capitalize"; align:right;}
                              	</style>
                              </head>
                              <body>
                              <div align=center>
                              <table  cellspacing=15>
                              <caption><h1>SignUp</h1></caption>
                              <tr>
                                     <td class=F>last name</F></td>
                                     <td colspan="3" width=150><input type=text  name="nom" >
                              	   <td class=F>first  name</td>
                                     <td colspan="3"><input type=text  name="prenom"></td>
                              </tr>
                              <tr>
                              	   <td class=F>father name</td>
                                     <td colspan="3"><input type=text name="perenom"></td>
                              	   <td class=F>date of birth</td>
                                     <td colspan="3" ><input type=text name="dob"></td>
                              </tr>
                              <tr>
                                     <td class=F>telephone</td>
                                     <td colspan="3"><input type=text name="phone"></td>
                              	   <td class=F>email</td>
                                     <td colspan="3"><input type=text name="mail"></td>
                              </tr>
                              <tr>
                                     <td class=F>country</td>
                                     <td colspan="3"><input type=text name="ville"></td>
                              	   <td class=F>rue</td>
                                     <td colspan="3"><input type=text name="rue"></td>
                              </tr>
                              <tr>
                                     <td class=F>immeuble</td>
                                     <td colspan="3"><input type=text name="immeuble"></td>
                              </tr>
                              <tr>
                                     <td class=F>identity card</td>
                                     <td colspan="3"><input type=file name="idcard"></td>
                              	   <td class=F>papaer of success</td>
                                     <td colspan="3"><input type=file name="pps"></td>
                              </tr>
                              <tr>
                                     <td class=F>user name</td>
                                     <td colspan="3"><input type=text name="userNom"></td>
                              </tr>
                              <tr>
                                     <td class=F>password</td>
                                     <td colspan="3"><input type=password name="pass"></td>
                              	   <td class=F>confirm password</td>
                                     <td colspan="3"><input type=password name="pass"></td>
                              
                                     <td colspan="2"><input type="submit" name="submit" value="submit" width="70%" height="40%"></td>
                              	   <td><input type="reset" name="reset" value="Clear" width="100%" height="50%"></td>
                              </tr>
                              </table>
                              <?php
                              include("essai.php");
                              $insert="INSRET INTO 'etudiante'
                              VALUES('',$nom,
                               '$prename', '$perenom', '$dob', '$phone', '$mail', '$ville', '$rue', '$immeuble', '$idcaed', '$pps','$userNom', MD5('$pass'))";
                               $result= mysql_query($insert);
                               if($result)
                               {
                               	header("Location:Acceptance.php");
                               }
                               else
                               {
                               	echo("You have missing or wrong input infomation". mysql_error());
                               }
                               mysql_close();
                               ?>
                              
                              </body>
                              </form>
                              </html>

                              Comment

                              Working...