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
386 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
join tables 4 56
update joined tables 2 55
How can i make performance tuning to my sql query? 6 54
BACKUP of mysql database from mysql server - using Coldfusion 9 42
Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 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