Jump to content

SK1990

Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Female
  • Location
    USA

SK1990's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I added the databasename.table and that helped.. and granted the user priviledges.. now everything shows up except the data fields in the table
  2. now i get this: SELECT command denied to user 'test@localhost' for table 'customer'
  3. I don't know what version of php sorry, the instructor gave the php template to work off of so all the php is his. This is for an SQL class.
  4. customer was spelt with a small c in the database, i had it as a capital C..i changed it to lowercase and uploaded.. still no such luck
  5. it's throwing the error on line 76.. which is this line while($row = mysql_fetch_array($result))
  6. I'm trying to embed a sql query into my php on my html page. I keep getting the error mysql_fetch_array() expects parameter 1 to be resource, boolean is given. What am I doing wrong? (Please note I'm not well versed in PHP and need specific directions on how to change my code) <?php require_once('auth.php'); ?> <html> <!-- This is the stub page for tying in your final project database into the website --> <!-- Don't forget to add premissions to your final project database so that your user can access it --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Final Project</title> </head> <body> <h1>Final project page <?php echo $_SESSION['SESS_FIRST_NAME'];?></h1> <p>This is where you will link in your final project database</p></br> <p>Good luck!</p></br> <div id="innerWrapper"> <!--start of sql embedding --> <a href="index.php">Login Page</a> | <a href="amenu.php">Menu Page</a> | <a href="logout.php">Logout</a> <h2>Customer Contact Info:</h2> <?php //Verified passwords $vlogin=$_SESSION['vlogin']; $vpassword=$_SESSION['vpasswd']; //This is the connection string for the database, server, username and password $con = mysql_connect("localhost",$vlogin,$vpassword); //CASE SENSITIVE if (!$con) { die('Could not connect: ' . mysql_error()); } //This is the connection string for the database, server, username and password $con = mysql_connect("localhost",$vlogin,$vpassword); //CASE SENSITIVE if (!$con) { die('Could not connect: ' . mysql_error()); } // Actually using the connection string and connecting to the database like the 'use' command mysql_select_db("finalprojectdb", $con); //The actual SQL code that will return a table structure into the local variable $result //Important note, PHP variables are case sensitive $result = mysql_query("SELECT Cust_Num, Contact_Name, Contact_Phone from Customer order by Cust_Num"); //constructing the table and column names //ECHO allows HTML to go through PHP to the server echo "<table border=''> <tr> <th>Customer Number</th> <th>Contact Name</th> <th>Contact Phone</th> </tr>"; // Looping until there are no more records from $result //If there are records, print the colum for that row //also ECHO allows HTML to pass through PHP while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['CUST_NUM'] . "</td>"; echo "<td>" . $row['CONTACT_NAME'] . "</td>"; echo "<td>" . $row['CONTACT_PHONE'] . "</td>"; echo "</tr>"; } echo "</table>"; //Closing the SQL connection string mysql_close($con); ?> </div> <div> [<a href="aMenu.php">Return to home page</a>] </div> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.