Solved

Database beginner here - PHP LANGUAGE USED MYSQL SOFTWARE USED - implemented DATABASE USING PHPMYADMIN WHEN I WROTE THE CODE IN PHP TO CALL THE DATABASE SO I CAN SEE THE OUTPUT OF THE DATABASE

Posted on 2004-04-03
5
381 Views
Last Modified: 2010-05-18
Hello Techies out there. I am  stepping into a new area and I am very raw. It is database w/php and mysql . I am using phpmyadmin and dreamweaver to write the code (because its better for me cause its color coded and I see what certain tags do)

Uh, I created  a simple database called "NBA PLAYERS" with a table inside it called old_timers that table is then broken down into 5 groups which reflects the positions that are available ie. (shootingguards, pf, smallfowards, point guards and centers ) and I populated these tables with players I then saved the database and started to write a simple php file that I read from o'reilly php & mysql cookbook. I then upload the code onto my websites server but when I tyoed in the url of the page in my browser the page came back just a blank white page ( www.deanvlacich.com/test.php) no errors whatsoever , I know my hosting company supports php syntax because in the past I wrote small blocks of code and uploaded it and it worked. I really need to get this right. I am unemployed individual so I am trying to learn and understand as much things as possible I will include the code below as I said before no error messages were seen on screen can somebody help me out SOS. MAYDAY

<?

include 'db.inc';


?>
<!DOCTYPE HTML PUBLIC
               "-//W3C//DTD HTML 4.0 Transitional//EN"
               "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>TEST</title>
</head>
<body><pre>
<?php
   
   $connection = mysql_connect("localhost");

   mysql_select_db("NBA PLAYERS", $connection);

   // (2) Run the query on the winestore through the
   //  connection
   $result = mysql_query ("SELECT * Shootguards, Point Guards, Snall Fowards , Power Forwards , Centers FROM old_timers WHERE 1 ORDER BY Snall Fowards ASC LIMIT 0, 30', $connection");

   // (3) While there are still rows in the result set,
   // fetch the current row into the array $row
   while ($row = mysql_fetch_row($result))
   {
     // (4) Print out each element in $row, that is,
     // print the values of the attributes
     for ($i=0; $i<mysql_num_fields($result); $i++)
       echo $row[$i] . " ";

     // Print a carriage return to neaten the output
     echo "\n";
   }
   // (5) Close the database connection
   mysql_close($connection);
?>
</pre>
</body>
</html>  
0
Comment
Question by:dean3740
5 Comments
 
LVL 9

Expert Comment

by:Alf666
ID: 10748865
Your mysql_connect line should include your mysql username and password :

   $connection = mysql_connect("localhost", "your_username", "your_password");

0
 

Author Comment

by:dean3740
ID: 10748912
even if i served from my webserver from my hosting company? do you my username and password defined by sql? i tried that still white blank page,

0
 
LVL 9

Expert Comment

by:Alf666
ID: 10749549
You must have a username/password combination allowed to talke to your MySQL.

Can I suggest the following code ? :

$db_selected = mysql_select_db("NBA PLAYERS", $connection);

if (!$db_selected) {
   die ('Can\'t use db : ' . mysql_error());
}

This should give you much more verbose debug.

0
 
LVL 7

Expert Comment

by:madwax
ID: 10841150
If you want you can read my article on using mysql with php through a db-connection class that handles everything with connection, databasechoosing etc:

http://www.ivtaco.se/articles/article.php?articleID=1

//jan


0
 
LVL 1

Accepted Solution

by:
smphil earned 275 total points
ID: 11147737
Try changing your script to this you should get the errors then! I added it in allready just cut and pastes it! Hope it works

("SELECT * Shootguards, Point Guards, Snall Fowards , Power Forwards , Centers FROM old_timers WHERE 1 ORDER BY Snall Fowards ASC LIMIT 0, 30', $connection")or die(mysql_error());
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now