Hey guys. I could really use your help. I know VERY little about PHP. I have only been working with it for a few weeks. I am working on an e-mail project for a course at the university. I am getting only the blank page. 🙁 I am getting myself confused the more that I try this. Can you please look at my source code and give me any suggestions? Thank you so much!
Thanks,
Angel

<? php

$authuser = '1234';

$username = "*";
$password = "
***";
$db = "angel_test";

mysql_connect('localhost', $username, $password);
mysql_select_db($db);

echo "This works.. BEFORE the query!";

$query = "Select messageFrom, messageSubject, messageDate
from cw_message
where user = $authuser";
$results = mysql_query($query)or die("Could not execute query".mysql_error());

echo "This works AFTER the query!";

$numRows = mysql_num_rows($result);

mysql_close();

echo "The part works after the mysql_close!";

$counter = 0;
while ($row == mysql_fetch_array($result))
{

	echo $row ['messageFrom']."<BR>";
	echo $row ['messageSubject']."<BR>";
	echo $row ['messageDate']."<BR>";

$counter++;

echo "The While Statement Works!";
}	

echo "This Works!";

?>

    Ii'm confused, are you saying that when you run this script you get nothing but a blank page?

    If so, enable error reporting. Put this at the top after <?php

    error_reporting(E_ALL);

      You had a space between <? and php like this <? php it must be <?php (no space that is why your page did not show). Then I took out some whit space and corrected calls to result and result which were probably typos or overlooking you code carefully but when you get a blenk page it would have been hard to tell.

      <?php
      $authuser = '1234';
      $username = "root";
      $password = "";
      $db = "angel_test";
      mysql_connect('localhost', $username, $password);
      mysql_select_db($db);
      //echo "This works.. BEFORE the query!";
      $query = "SELECT  messageFrom, messageSubject, messageDate
      FROM cw_message WHERE user = $authuser";
      $result = mysql_query($query)or die("Could not execute query".mysql_error());
      //echo "This works AFTER the query!";
      $numRows = mysql_num_rows($result);
      mysql_close();
      //echo "The part works after the mysql_close!";
      $counter = 0;
      while ($row = mysql_fetch_array($result))
      {
      echo $row ['messageFrom']."<BR />";
      echo $row ['messageSubject']."<BR />";
      echo $row ['messageDate']."<HR />";
      $counter++;
      //echo "The While Statement Works!";
      }
      //echo "This Works!";
      ?>.
      

      Just run it and if it works then let us know about it and mark this post resolved with the Thread tools available in each thread.

        Thank you guys so much for trying to help me. I have been crying all night from frustration. I appreciate the help. I ran the code. This is what I got when I ran the program:

        Could not execute queryUnknown column 'user' in 'where clause'

        Please let me know if you have any ideas. I am so sorry to be such a pain! 🙁

        Thanks again,
        Angel

          From the looks of your code I had assumed that you had a column for user so I put one into a test database, so you will either need to add a column 'user' or change the query here is the SQL structure for how I tested your script.

          CREATE TABLE `cw_message` (
            `id` smallint(4) NOT NULL auto_increment,
            `message` text NOT NULL,
            `messageFrom` varchar(35) NOT NULL,
            `messageSubject` varchar(35) NOT NULL,
            `messageDate` datetime NOT NULL,
            `user` varchar(35) NOT NULL,
            PRIMARY KEY  (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
          
          -- 
          -- Dumping data for table `cw_message`
          -- 
          
          INSERT INTO `cw_message` VALUES (1, 'This is the test turkey message just to fool around with the database.', 'Steve', 'Turkeys', '2006-04-11 20:02:00', '1234');
          INSERT INTO `cw_message` VALUES (2, 'This is another funny message just for testing to see what ', 'Robert', 'Bees', '2006-04-11 00:00:00', '1234');

          Run That query and it will make two rows in your database and your code will work.
          OR just change your query to this and you can test without adding a user field.

          $query = "SELECT  messageFrom, messageSubject, messageDate
          FROM cw_message ";

            Finally got this response.... is it good? Looks like i still need to add some kind of date/time functions?

            This works.. BEFORE the query!This works AFTER the query!The part works after the mysql_close!userb
            cool
            0000-00-00 00:00:00
            The While Statement Works!usert
            awesome
            0000-00-00 00:00:00
            The While Statement Works!userq
            awesome
            0000-00-00 00:00:00
            The While Statement Works!This Works!.

            Houdini thanks so much for the help. If you have yahoo messenger or windows messenger you can write me at angelkay73 at either of those.. if you think it would be quicker. THANK YOU, THANK YOU, THANK YOU FOR THE HELP!! I have felt so completely alone and completely stupid with this stuff. I really do appreciate it!!

            Thanks,
            Angel

              I still feel stupid about some of it also, now you can carry on, and know to look more carefully at you code. Nothing is worse than code that misbehaves especially when you are firs getting started. At least here there are those that are pretty good at solutions and perhaps suggestions.

              I doubt you will let the <? php get you again
              If you wil use the INSERT INTO blah blah that I provided you will have messages and user all the necessary in your sample database.

                I have only been doing this for a few weeks.. and I am not great at programming in general. I get too frustrated I guess. 🙁 I still have one more part to finish this project. Any chance that you can continue to help me this week. I don't even know where to begin in the next part. I could sure use a tutor.

                  I don't have my papers in here or I would tell you the exact assignment. It is just continuing to build on this email project. It is just crazy for me to try to do something like this when I know VERY LITTLE about PHP, and I am programming impaired already! 🙁 This is my last semester at school. And I can promise you that I am NOT a programming major! 😃 If I can get this email project working it will be a mountain off of my shoulders.

                    Well it would probably involve the mail() function and it is not that hard to work with it only accept 5 parameters and of thse only three are required but usually you would use 4 of them, so I can do the email thing. They are just teaching about a database query so you can know how to retrieve information or insert possibly update it. It is not really that difficult. Well just post what your deal is and if I don't get to it someone else here will usually within a short period of time.

                    It is late here and I am ready for bed so right now I gotta say bye.

                      OK.. thanks again for everything! I really appreciate you!!

                        I smell love in the air...

                        Dominic Son

                        BackState.com
                        "We've got your back"bone server!

                          Write a Reply...