Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 825 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

609 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