Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot connect to my hosting service's MySql database. NB
    primarykey
    data
    text
    <p>I am EXTREMELY new to the html/php scene but I have been working at this for hours. I am stumped. </p> <p><strong>I am trying to connect to a sql database that will store username and password information.</strong> I use fortune city for hosting and I have already used their phpAdmin to setup up all of the necessary stuff (db, tables, etc..). </p> <p>I am using Eclipse with Zend on the side. I am also running Sql Server and Apache 2.2. </p> <p><strong>I believe my issue is the following:</strong></p> <p>I have a db located at a certain ip address (<em>remote fortunecity server</em>) and I am testing my project on the local server. Fortune city offers two different host names, one for internal connections and one for external connections. I get different results from each one:</p> <p>If I connect to the internal site it doesn't make any connection, I know this because of my die statement. If I connect to the external host it connects, but doesn't allow me to connect to the database. (<em>see cases below code</em>)</p> <p>Currently my process is as follows. (<strong>PLEASSSSE TELL ME A BETTER WAY IF I'M DOING THINGS THE INEFFICIENTLY, I feel dirty every time I do it!!</strong>)</p> <ol> <li>Create or edit my index.php, login.php, etc... in eclipse.</li> <li>Copy the files that I edit into my Apache root.</li> <li>Go back to eclipse and run the project in a browser "firefox."</li> <li>repeat n to the n times.</li> </ol> <p><em>Keep in mind my sql database is located on the net</em></p> <p><strong>Can this be done? Testing locally while accessing a db on the net?</strong></p> <p>Here is the code:</p> <pre><code>&lt;?php if (!isset($_POST['username']) || !isset($_POST['password'])) { header( "Location: http://localhost/index.php" ); } elseif (empty($_POST['username']) || empty($_POST['password'])) { header( "Location: http://localhost/index.php" ); } else{ $user = addslashes($_POST['username']); $pass = md5($_POST['password']); $dbHost = "mysql3341.dotsterhost.com"; $dbUser = "*********"; $dbPass = "******"; $dbDatabase = "**********"; $db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database."); mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database."); $result=mysql_query("select * from userInfo where username='$user' AND password='$pass'", $db); $rowCheck = mysql_num_rows($result); if($rowCheck &gt; 0){ while($row = mysql_fetch_array($result)){ session_start(); session_register('username'); echo 'Success!'; header( "Location: checkLogin.php" ); } } else { echo 'Incorrect login name or password. Please try again.'; } } ?&gt; </code></pre> <p>Again, I have never made it past <p>Case :1 <code>$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");</code></p> <p>Case :2 <code>mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");</code></p> <p>Thanks for reading my novel!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload