473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

connection to sql

Leen
22
i want connect to sql
this is my page "MySqlConnection.php":
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     $cite_school=mysql_connec("localhost","****","****");
  3.     $cite_bdd=mysql_select_db("ecole");
  4.     if(!$cite_school||!$cite_bdd)
  5.     {
  6.         die("Connexion impossible à la base de données". mysql_error());
  7.     }
  8. ?>
what is the problem?
Aug 24 '10 #1

✓ answered by Atli

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.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Enable error reporting
  3. ini_set('display_errors', true);
  4. error_reporting(E_ALL + E_NOTICE);
  5.  
  6. // Make sure the mysql extension is available
  7. if(!function_exists("mysql_connect")) {
  8.     die("MySQL extension not available.");
  9. }
  10.  
  11. // Try to connect
  12. if(!($dbLink = mysql_connect("localhost", "usr", "pwd"))) {
  13.     die("failed to connect to MySQL: " . mysql_error());
  14. }
  15. if(!mysql_select_db("ecole", $dbLink)) {
  16.     die("Failed to select db: " . mysql_error());
  17. }
  18.  
  19. // It worked!
  20. echo "Success! You can connect to your MySQL database without problems.";
  21. ?>

26 2582
TheServant
1,168 Expert 1GB
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_connec".
Aug 24 '10 #2
Leen
22
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 "MySQLConnect", 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
Aug 25 '10 #3
TheServant
1,168 Expert 1GB
Try run this, and post exactly what is returned:
Expand|Select|Wrap|Line Numbers
  1. mysql_connect('localhost', '****', '****') or die("Could not connect: ".mysql_error());
  2. mysql_select_db('ecole') or die("Could not select ecole: ".mysql_error());
Aug 25 '10 #4
Leen
22
i try it.
when i open this page in "internet explorer", i get blanc page.
does that mean that there is connection to database??
Aug 27 '10 #5
TheServant
1,168 Expert 1GB
Try adding:
Expand|Select|Wrap|Line Numbers
  1. error_reporting(E_ALL);
  2. ini_set('display_errors', 'on');
To the top of your page. Tell us what is says after that.
Aug 27 '10 #6
Leen
22
also i get blanc page
Aug 28 '10 #7
TheServant
1,168 Expert 1GB
Sorry, I should have made this clearer.
Put in a page:
Expand|Select|Wrap|Line Numbers
  1. error_reporting(E_ALL);
  2. ini_set('display_errors', 'on');
  3. mysql_connect('localhost', '****', '****') or die("Could not connect: ".mysql_error());
  4. 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?
Aug 28 '10 #8
Leen
22
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.
Aug 28 '10 #9
Atli
5,058 Expert 4TB
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.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Enable error reporting
  3. ini_set('display_errors', true);
  4. error_reporting(E_ALL + E_NOTICE);
  5.  
  6. // Make sure the mysql extension is available
  7. if(!function_exists("mysql_connect")) {
  8.     die("MySQL extension not available.");
  9. }
  10.  
  11. // Try to connect
  12. if(!($dbLink = mysql_connect("localhost", "usr", "pwd"))) {
  13.     die("failed to connect to MySQL: " . mysql_error());
  14. }
  15. if(!mysql_select_db("ecole", $dbLink)) {
  16.     die("Failed to select db: " . mysql_error());
  17. }
  18.  
  19. // It worked!
  20. echo "Success! You can connect to your MySQL database without problems.";
  21. ?>
Aug 28 '10 #10
Leen
22
thank u verry much
Aug 29 '10 #11
Leen
22
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:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <form method="post" action="SignUp.php">
  3. <body>
  4. <div align=center>
  5. <table  cellspacing=15>
  6. <caption><h1>SignUp</h1></caption>
  7. <tr>
  8.        <td class=F>last name</F></td>
  9.        <td colspan="3" width=150><input type=text  name="nom" >
  10.        <td class=F>first  name</td>
  11.        <td colspan="3"><input type=text  name="prenom"></td>
  12. </tr>
  13. <tr>
  14.        <td class=F>father name</td>
  15.        <td colspan="3"><input type=text name="perenom"></td>
  16.        <td class=F>date of birth</td>
  17.        <td colspan="3" ><input type=text name="dob"></td>
  18. </tr>
  19. <tr>
  20.        <td class=F>telephone</td>
  21.        <td colspan="3"><input type=text name="phone"></td>
  22.        <td class=F>email</td>
  23.        <td colspan="3"><input type=text name="mail"></td>
  24. </tr>
  25. <tr>
  26.        <td class=F>country</td>
  27.        <td colspan="3"><input type=text name="ville"></td>
  28.        <td class=F>rue</td>
  29.        <td colspan="3"><input type=text name="rue"></td>
  30. </tr>
  31. <tr>
  32.        <td class=F>immeuble</td>
  33.        <td colspan="3"><input type=text name="immeuble"></td>
  34. </tr>
  35. <tr>
  36.        <td class=F>identity card</td>
  37.        <td colspan="3"><input type=file name="idcard"></td>
  38.        <td class=F>papaer of success</td>
  39.        <td colspan="3"><input type=file name="pps"></td>
  40. </tr>
  41. <tr>
  42.        <td class=F>user name</td>
  43.        <td colspan="3"><input type=text name="userNom"></td>
  44. </tr>
  45. <tr>
  46.        <td class=F>password</td>
  47.        <td colspan="3"><input type=password name="pass"></td>
  48.        <td class=F>confirm password</td>
  49.        <td colspan="3"><input type=password name="pass"></td>
  50.  
  51.        <td colspan="2"><input type="submit" name="submit" width="70%" height="40%"></td>
  52.        <td><input type="reset" name="submit" value="Clear" width="100%" height="50%"></td>
  53. </tr>
  54. </table>
  55.  
  56. </body>
  57. </form>
  58. </html>
and this is SignUp.php:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <?php
  3. SESSION_start();
  4. $nom=$_POST['nom'];
  5. $prenom=$_POST["prenom"];
  6. $perenom=$_POST["perenom"];
  7. $dob=$_POST["dob"];
  8. $phone=$_POST["phone"];
  9. $mail=$_POST["mail"];
  10. $ville=$_POST["ville"];
  11. $rue=$_POST["rue"];
  12. $immeuble=$_POST["immeuble"];
  13. $idcard=$_POST["idcard"];
  14. $pps=$_POST["pps"];
  15. $userNom=$_POST["userNom"];
  16. $pass=$_POST["pass"];
  17. include("essai.php");
  18. $insert="INSRET INTO 'etudiante'
  19. VALUES('',$nom,
  20.  '$prename', '$perenom', '$dob', '$phone', '$mail', '$ville', '$rue', '$immeuble', '$idcaed', '$pps','$userNom', MD5('$pass'))";
  21.  $result= mysql_query($insert);
  22.  if($result)
  23.  {
  24.      header("Location:Acceptance.php");
  25.  }
  26.  else
  27.  {
  28.      echo("You have missing or wrong input infomation". mysql_error());
  29.  }
  30.  mysql_close();
  31.  ?>
  32.  </html>
  33.  
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'???
Aug 29 '10 #12
Atli
5,058 Expert 4TB
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.
Aug 29 '10 #13
Leen
22
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?
Aug 30 '10 #14
Leen
22
this is my new page
i have join the 2 pages in one, but also false...why?
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     include("entete.html");
  3. ?>
  4. <html>
  5. <form method="post">
  6. <head>
  7.     <title>Sign Up</title>
  8.     <Style type="text/css">
  9.     .text {width:785px;}
  10.     .F { font-family: "Verdana"; font-size: 20px; text-transform: "capitalize"; align:right;}
  11.     </style>
  12. </head>
  13. <body>
  14. <div align=center>
  15. <table  cellspacing=15>
  16. <caption><h1>SignUp</h1></caption>
  17. <tr>
  18.        <td class=F>last name</F></td>
  19.        <td colspan="3" width=150><input type=text  name="nom" >
  20.        <td class=F>first  name</td>
  21.        <td colspan="3"><input type=text  name="prenom"></td>
  22. </tr>
  23. <tr>
  24.        <td class=F>father name</td>
  25.        <td colspan="3"><input type=text name="perenom"></td>
  26.        <td class=F>date of birth</td>
  27.        <td colspan="3" ><input type=text name="dob"></td>
  28. </tr>
  29. <tr>
  30.        <td class=F>telephone</td>
  31.        <td colspan="3"><input type=text name="phone"></td>
  32.        <td class=F>email</td>
  33.        <td colspan="3"><input type=text name="mail"></td>
  34. </tr>
  35. <tr>
  36.        <td class=F>country</td>
  37.        <td colspan="3"><input type=text name="ville"></td>
  38.        <td class=F>rue</td>
  39.        <td colspan="3"><input type=text name="rue"></td>
  40. </tr>
  41. <tr>
  42.        <td class=F>immeuble</td>
  43.        <td colspan="3"><input type=text name="immeuble"></td>
  44. </tr>
  45. <tr>
  46.        <td class=F>identity card</td>
  47.        <td colspan="3"><input type=file name="idcard"></td>
  48.        <td class=F>papaer of success</td>
  49.        <td colspan="3"><input type=file name="pps"></td>
  50. </tr>
  51. <tr>
  52.        <td class=F>user name</td>
  53.        <td colspan="3"><input type=text name="userNom"></td>
  54. </tr>
  55. <tr>
  56.        <td class=F>password</td>
  57.        <td colspan="3"><input type=password name="pass"></td>
  58.        <td class=F>confirm password</td>
  59.        <td colspan="3"><input type=password name="pass"></td>
  60.  
  61.        <td colspan="2"><input type="submit" name="submit" value="submit" width="70%" height="40%"></td>
  62.        <td><input type="reset" name="reset" value="Clear" width="100%" height="50%"></td>
  63. </tr>
  64. </table>
  65. <?php
  66. include("essai.php");
  67. $insert="INSRET INTO 'etudiante'
  68. VALUES('',$nom,
  69.  '$prename', '$perenom', '$dob', '$phone', '$mail', '$ville', '$rue', '$immeuble', '$idcaed', '$pps','$userNom', MD5('$pass'))";
  70.  $result= mysql_query($insert);
  71.  if($result)
  72.  {
  73.      header("Location:Acceptance.php");
  74.  }
  75.  else
  76.  {
  77.      echo("You have missing or wrong input infomation". mysql_error());
  78.  }
  79.  mysql_close();
  80.  ?>
  81.  
  82. </body>
  83. </form>
  84. </html>
Aug 30 '10 #15
Dormilich
8,658 Expert Mod 8TB
to fix one obvious mistake, <form> must be placed inside <body> (see also validator.w3.org)
Aug 31 '10 #16
MrMancunian
569 Expert 512MB
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! ;)
This is very subjective. In the future, phrase this as "I think of IE as a horrible browser", as your opinion does not necessarily has to reflect reality. I use IE for development and I have no problems whatsoever.

Steven
Aug 31 '10 #17
Leen
22
this is reply for "Dormilich":
thank u.
i place form inside body, but this is not here the problem.
and i use validator.w3.org, but it doesn't detect the main problem
Aug 31 '10 #18
Leen
22
this is reply for "Dormilich":
thank u.
i place form inside body, but this is not here the problem.
and i use validator.w3.org, but it doesn't detect the main problem
Aug 31 '10 #19
Dormilich
8,658 Expert Mod 8TB
I didn’t think it would be the cause of the problem, though it’s always good practice to have valid HTML (which can cause other problems).
Aug 31 '10 #20
Leen
22
but my problem is in php not in html..
Aug 31 '10 #21
Atli
5,058 Expert 4TB
This doesn't sound like a problem in your code. If you are getting "The connection was reset" as an error message, it sounds more like a problem with your server configuration.

Could also be that something in your PHP code is causing a timeout. Do you have to wait long until the error message is shown?

Could you tell us more about your server? Like the OS you are running, and the versions of the server software. Also, any firewall or such you are running.
Aug 31 '10 #22
Atli
5,058 Expert 4TB
This is very subjective. In the future, phrase this as "I think of IE as a horrible browser", as your opinion does not necessarily has to reflect reality. I use IE for development and I have no problems whatsoever.
This is not an opinion, sadly. IE has horrible standards support and a very bad track record when it comes to bugs. Doesn't take much research to verify this. (Just make sure to avoid Microsoft's own propaganda. There is a lot of it out there.)

Not to mention that if you try to adhere to the standards when creating websites, you usually have to work around a few IE bugs/incompatibilities. A lot of us even have "standard" IE standards support fixes we include by default to avoid the brunt of it.
Aug 31 '10 #23
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_connect("localhost","root","")or die("not connected");
  3. mysql_select_db("db name")or die("db not connected".mysql_error());
  4. ?>
Sep 1 '10 #24
Leen
22
No we don't have to wait to long as we load the page it gives us "The connection was reset"
also we are working on windows 7
and the program is WAMP version 2.0
and we are using Firefox version of mozilla is 3.6.8
Sep 1 '10 #25
kovik
1,044 Expert 1GB
I know that, in Internet Explorer at least, your error oftentimes implies PHP errors. When there are errors in a page, your server sends an HTTP 500 response. Internet Explorer takes the HTTP 500 response and runs with it. You can check for the exact errors by checking your error logs. Since you are using an Apache set up, you can find it in the error.log file in the logs folder. i.e. c:\wamp\logs\error.log

Looking at your code, I assume that you WILL find errors. You don't check if $_POST variables are empty, you spelled "INSERT" incorrectly, and you attempt to send headers after output has already been made to the browser.
Sep 1 '10 #26
kovik
1,044 Expert 1GB
@MrMancunian: How can you claim to use IE for development? Each version of IE renders differently. You'd have to have IE6, IE7, and IE8 up to be able to claim that you support IE.

Which is what I have to do all the time. -_-

I'm scared of what problems IE9 will carry with it. I assume buggy CSS3 and HTML5, if they even follow through with it. To Microsoft, HTML5 is a buzzword.
Sep 1 '10 #27

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: G-Fit | last post by:
Hello group, I have several servers hosting SQL databases. On each of them, I have several databases. All those databases have the same structure (even those on different servers), only the data...
11
by: pradeep_TP | last post by:
Hi all, I have a few questions that I have been wanting to ask for long. These are all related to ADO.net and specifically to conenction to database. 1) If I have opened a connection to a...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
35
by: Terry Jolly | last post by:
Web Solution Goal: Have a global database connection Why: (There will be 30+ tables, represented by 30+ classes) I only want to reference the database connection once. I put the connection...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
3
by: fniles | last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like the following: In the main form load I open a connection using a connection string that I stored in a global variable...
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.