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
377 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
Comment Utility
Your mysql_connect line should include your mysql username and password :

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

0
 

Author Comment

by:dean3740
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

10 Experts available now in Live!

Get 1:1 Help Now