Jump to content

PrettyHotProgrammer

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Posts posted by PrettyHotProgrammer

  1. They are in Different Files... the form is in a file called NewAssignment.php and it goes to NewAssignment3.php and the Config file is just Simply full of Variables that I am using... that is where I am storing everything I will try to do the echo statement that you suggested but Nothing is printing out and I think that that means there is an error somewhere that is crashing the entire thing... This is killing me...

     

    Thanks for all of your help... i'm going to stay up all night tonight and stress over it so if anyone can help at all please let me know!!

  2. I changed some stuff... it still isn't working... it must have been a PHP error because it was not even getting to the MySQL statements...

     

     

    Here is the code now...

    <?php

      //Error Reporting On

      ini_set('display_errors','on');

      error_reporting(E_ALL ^ E_NOTICE);

     

     

      $Remove = $_POST[removeAID];

     

      include("config.php");

      if (!($db = mysql_pconnect($hostname, $username , $password))){

            die("Can't connect to database server.");

          }else{

            // select a database

           

            if (!(mysql_select_db("$database",$db))){

                die("Can't connect to database.");

            }

          }

        $sql = "DELETE FROM `Assignment` WHERE `AssignmentID` = '$Remove'";

     

      mysql_query($sql)

        or die(mysql_error().' - '.$sql);

    header("Location: MyURL");");

      exit;

    ?>

     

     

    Here is the Form...

        <form action="NewAssignment3.php" method="post">

        <table width = "100%" border="5">

            <tr>

                <td width="33%" align="center"> Remove At Assignment ID</td>

                    <td width="33%" align="center"><input type="text" size="10" name="removeAID"></td>

                    <td width="33%" align="center"><input type="submit" />

                </tr>

            </table>

        </form>

  3. Shoulda Seen that...

     

    now I am getting

     

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

  4. I am not getting the Rows deleted when i do this?

     

    <?php

     

    header("Location: URL where I want it redirected");

     

    $aid=$_POST[aid];

    $aName=$_POST[aName];

    $sid=$_POST[sid];

    $description=$_POST[description];

     

    include("configuration.php");

    if (!($db = mysql_pconnect($hostname, $username , $password))){

    die("Can't connect to database server.");

    }else{

    // select a database

     

    if (!(mysql_select_db("$database",$db))){

    die("Can't connect to database.");

    }

    }

    $sql = "DELETE FROM Assignment WHERE AssignmentID = $aid";

     

    mysql_query($sql);

    or die(mysql_error());

    ?>

  5. Thank you all for all of you help... I finally figured it out it was a pain but i found it on ScriptPlayground

     

    here is the code for future people looking for this!!

     

     <?php
    include("config.php");
    
    if (!($db = mysql_pconnect($hostname, $username , $password))){
             die("Can't connect to database server.");
          }else{
             // select a database
             
             if (!(mysql_select_db("$database",$db))){
                die("Can't connect to database.");
             }
          }
    
    function display_db_query($query_string, $header_bool, $table_params)
    {
    // perform the database query
    	$result_id = mysql_query($query_string)
    		or die("display_db_query:" . mysql_error());
    
    // find out the number of columns in result
    	$column_count = mysql_num_fields($result_id)
    		or die("display_db_query:" . mysql_error());
    
    // Here the table attributes from the $table_params variable are added
    	print("<TABLE $table_params >\n");
    
    // optionally print a bold header at top of table
    	if ($header_bool)
    	{
    		print("<TR>");
    		for ($column_num = 0; $column_num < $column_count; $column_num++)
    		{
    			$field_name = mysql_field_name($result_id, $column_num);
    			print("<TH>$field_name</TH>");
    		}
    		print("</TR>\n");
    	}
    
    // print the body of the table
    	while ($row = mysql_fetch_row($result_id))
    	{
    		print("<TR ALIGN=LEFT VALIGN=TOP>"); 
    		for ($column_num = 0; $column_num < $column_count; $column_num++)
    		{
    			print("<TD>$row[$column_num]</TD>\n");
    		}
    		print("</TR>\n");
    	}
    	print("</TABLE>\n"); 
    }
    
    function display_db_table($tablename, $header_bool, $table_params)
    {
    $query_string = "SELECT * FROM $tablename";
    display_db_query($query_string,$header_bool, $table_params);
    }
    ?>
            <TABLE border="2">
                    <TR>
                        <TD>
    					<?php
                            //In this example the table name to be displayed is  static, but it could be taken from a form
                            $table = $assignmentTable;
                            
                            display_db_table($table, $global_dbh, TRUE, "border='0'");
                            ?>
                        </TD>
                    </TR>
            </TABLE>      
        </body>
    </html>

  6. This is now my code... Still White Screen...

    I am used to programming in C# where when there is a problem you can step through it and find where it is not doing what it is supposed to... This is the Reason I should stay with my Windows Forms Programming haha

     

    <?php

      include("config.php");

          if (!($db = mysql_pconnect($hostname, $username , $password))){

            die("Can't connect to database server.");

          }else{

            // select a database

           

            if (!(mysql_select_db("$database",$db))){

                die("Can't connect to database.");

            }

          }

         

          $result = mysql_query("SELECT * FROM Assignment");

     

          $num_rows = mysql_num_rows($result);

         

          $i = 0;

         

          echo"<table width="100%" border="0">";

          echo"<tr>

                  <td>$nbsp;</td>

                  <td>Assignment ID</td>

                  <td>Title</td>

                  <td>School ID</td>

                  <td>Description</td>

                </tr>";

               

          while($row = mysql_fetch_array($result))

          {

                $query = "Select * from Assignment where AssnID = '$i'";

                                    $result = mysql_query($query);

            echo"

                <tr>

                  <td>$nbsp;</td>

                  <td>$row['Assignment']</td>

                  <td>$row['Title']</td>

                  <td>$row['SchoolID']</td>

                  <td>$row['Description']</td>

                </tr> 

            ";

            $i++

          }

          echo"</table>";

      ?>

  7. Here is my code...

    Configuration.php has all the variables for Database Hostname username password... I know the connection works..

     

    <?php

    include("configuration.php");

    if (!($db = mysql_pconnect($hostname, $username , $password))){

    die("Can't connect to database server.");

    }else{

    // select a database

     

    if (!(mysql_select_db("$database",$db))){

    die("Can't connect to database.");

    }

    }

     

    $result = mysql_query("SELECT * FROM Assignment");

     

    $num_rows = mysql_num_rows($result);

     

    $i = 0;

     

    echo"<table width="100%" border="0">";

    echo"<tr>

    <td></td>

    <td>Assignment ID</td>

    <td>Title</td>

    <td>School ID</td>

    <td>Description</td>

    </tr>";

     

    while($i < $num_rows+1)

    {

    $query = "Select * from Assignment where AssnID = $i";

                                    $result = mysql_query($query);

    $row = mysql_fetch_array($result);

    echo"

    <tr>

    <td>$row[1]</td>

    <td>$row[2]</td>

    <td>$row[3]</td>

    <td>$row[4]</td>

    </tr>

    ";

    }

    echo"</table>";

    ?>

     

    Thanks in advanced!!

×
×
  • 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.