Jump to content
Larry Ullman's Book Forums

BluesMatt

Members
  • Content Count

    7
  • Joined

  • Last visited

Everything posted by BluesMatt

  1. Yes HartleySan, I see what you are asking. I went around and around with lots of different versions of my code trying to get it to work. At one point, when I was doing some research online to solve my problem, someone suggested using mySQLi_connect instead of mySQL_connect (apparently mySQL_connect has been deprecated). When I contacted Hostgator and showed them my code, I was, at that point, using mySQLi_connect (and my code didn't work). The working code they returned had the 'i' removed. It doesn't look like they changed anything else in my code, but I'm not sure if they also ch
  2. Thanks for all the replies. The script is now working. Here's the updated code (with my password x'ed out). When I contacted my host (Hostgator), they removed the 'i' from the mySQL_connect function. <?php echo "My version"; echo "<br>"; echo "Trying to connect to query the mySQL server"; echo "<br> <br>"; $dbhandle = mysql_connect ('localhost', 'bluesmat_matt', 'xxxxxxxxxxxxxxxx') or die("Unable to connect to MySQL"); echo "Connected to MySQL<br>"; echo "<br>"; $selected = mysql_select_db ('bluesmat_test', $dbhandle) or die("Could not s
  3. OK, thanks for the replies. I tried "mysqli_connect" and got this warning: Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home3/bluesmat/public_html/test2.php on line 22 Could not select bluesmat_test I checked (again) in phpAdmin and unless my eyes are crossed, I have the database name spelled correctly. Maybe it doesn't like the '_' (underscore) in the name?
  4. Here's the updated code: <?php echo '9'; echo '<br>'; echo 'Trying to connect to query the mySQL server'; echo '<br> <br>'; define ('DB_USER', 'xxxxxxxxxxxxxxxxxx'); define ('DB_PASSWORD', 'xxxxxxxxxxxxxxxxxxxxx'); define ('DB_HOST', 'localhost'); // define ('DB_NAME', 'bluesmat_test'); $dbhandle = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die("Unable to connect to MySQL"); echo "Connected to MySQL<br>"; $selected = mysql_select_db ("bluesmat_test", $dbhandle) or die("Could not select bluesmat_test"); //my first query $resu
  5. Yes, this works in phpAdmin. Now I'm trying to get some records to display using php on my web page. For some reason $result is not being set to TRUE.
  6. OK. I solved the problem; my username for the database was incomplete. Now I am trying to do a simple query and display the 4 records from the small table I created. I can query the table in phpAdmin so I know the records are there. Here's my code (with the db name and password x'ed out): <?php echo '2'; echo '<br>'; echo 'Trying to connect to query the mySQL server'; echo '<br> <br>'; define ('DB_USER', 'xxxxxxxxx'); define ('DB_PASSWORD', 'xxxxxxx'); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'bluesmat_test'); $dbc = mysql
  7. Hello everyone. I am building my first php/mySQL website and I have a basic question. I am hosting my website at Hostgator. I have a very basic first index.html loaded on the server at Hostgator and I can access it from my PC's browser. I uploaded a simple php page with a simple 'echo' command and that works. I have built a tiny database using phpAdmin and it has 4 records with 3 fields each and I can query it using phpAdmin. Now I am trying to connect to it from a php web page. I used a modified version of script 6.4 in the book and when I run it, I get these errors: W
×
×
  • Create New...