O'Reilly Forums: Quick Question About Td On Page 201 - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Quick Question About Td On Page 201 Should I keep the html page even if it says otherwise?

#1 User is offline   doesit 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 06-November 12

Posted 06 November 2012 - 12:32 AM

I have coded the correct php from the chapter 4 zip files so I know that my code is correct. Eventhough it states that I should go ahead and delete my Html files, that is the only file that will allow me to synch with the php file. I am using a godaddy hosting account to test all of this out, Is this the problem? Did I leave anything out? Here is what my code looks like:


<?php
if (isset($_POST['submit'])) {
$from = 'abc123@abc123.com';
$subject = $_POST['subject'];
$text = $_POST['elvismail'];
$output_form = false;

if (empty($subject) && empty($text)) {
// We know both $subject AND $text are blank
echo 'You forgot the email subject and body text.<br />';
$output_form = true;
}

if (empty($subject) && (!empty($text))) {
echo 'You forgot the email subject.<br />';
$output_form = true;
}

if ((!empty($subject)) && empty($text)) {
echo 'You forgot the email body text.<br />';
$output_form = true;
}
}
else {
$output_form = true;
}

if ((!empty($subject)) && (!empty($text))) {
$dbc = mysqli_connect(''server'', 'database', 'password', 'elvis')
or die('Error connecting to MySQL server.');

$query = "SELECT * FROM email_list";
$result = mysqli_query($dbc, $query)
or die('Error querying database.');

while ($row = mysqli_fetch_array($result)){
$to = $row['email'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$msg = "Dear $first_name $last_name,\n$text";
mail($to, $subject, $msg, 'From:' . $from);
echo 'Email sent to: ' . $to . '<br />';
}

mysqli_close($dbc);
}

if ($output_form) {
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="subject">Subject of email:</label><br />
<input id="subject" name="subject" type="text" value="<?php echo $subject; ?>" size="30" /><br />
<label for="elvismail">Body of email:</label><br />
<textarea id="elvismail" name="elvismail" rows="8" cols="40"><?php echo $text; ?></textarea><br />
<input type="submit" name="submit" value="Submit" />
</form>

<?php
}
?>


If this particular issue has been answered disregard and redirect. Thanks folks in advance!
0

#2 User is online   drewdin 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 589
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

Posted 07 November 2012 - 06:20 AM

i have no idea what you are asking? Are you having a problem, is there an error?

This post has been edited by drewdin: 07 November 2012 - 06:20 AM

0

#3 User is offline   doesit 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 06-November 12

Posted 07 November 2012 - 12:38 PM

View Postdrewdin, on 07 November 2012 - 06:20 AM, said:

i have no idea what you are asking? Are you having a problem, is there an error?



Disregard the issue. It seems whenever I try to modify a new php file from the Test Drive(page 219 for example) it will give me an error message("No input selected). However when I give it some time say 15 minutes it will all of a sudden go through and the code will function properly. Will this be an issue in the future? Or will this just be a one time thing? Know anything about this?
0

#4 User is online   drewdin 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 589
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

Posted 07 November 2012 - 01:45 PM

I ran into issues with the downloaded files too, it seemed that if I wrote them myself they worked fine but if I used the downloaded files they gave me all kinds of errors. It must be something with the encoding of the files but I'm not sure.
0

#5 User is offline   doesit 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 06-November 12

Posted 09 November 2012 - 09:39 AM

Thanks Drewdin. I really appreciate it. I wonder if you could help me out real quick with this code on page 243. I wasn't able to find a post on resolving this issue.
I have this index.php code that I was working on with the Test Drive on the page. My code is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Guitar Wars - High Scores</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h2>Guitar Wars - High Scores</h2>
<p>Welcome, Guitar Warrior, do you have what it takes to crack the high score list? If so, just <a href="addscore.php">add your own score</a>.</p>
<hr />

<?php
// Connect to the database
$dbc = mysqli_connect('data@data', 'guitarwars', '', 'guitarwars');

// Retrieve the score data from MySQL
$query = "SELECT * FROM guitar table";
$data = mysqli_query($dbc, $query);

// Loop through the array of score data, formatting it as HTML
echo '<table>';
while ($row = mysqli_fetch_array($data)) {
// Display the score data
echo '<tr><td class="scoreinfo">';
echo '<span class="score">' . $row['score'] . '</span><br />';
echo '<strong>Name:</strong> ' . $row['name'] . '<br />';
echo '<strong>Date:</strong> ' . $row['date'] . '</td>';

if (is_file($row['screenshot']) && filesize($row["screenshot'])>0 {
echo '<td><img src="'.$row['screenshot'].'"alt="Score image"/></td></tr>';
}

else {

echo'<td><img src="unverified.gif"alt="Unverified score"/></td></tr>';
}

}
echo'</table>';

mysqli_close($dbc);
?>



The red highlighted is the one that is bring up this error:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in \\PHX3.GDHOSTING.GDG\P3NWHG528\hosting\67\9973567\html\guitarwars\index.php on line 32



I want to know what Im doing wrong. Now I took your advice as far as manually coding out the index.php scrip and Im still getting the same
error. Any thoughts on this?

</body>
</html>

This post has been edited by doesit: 09 November 2012 - 09:41 AM

0

#6 User is online   drewdin 

  • Super Veteran Member
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Members
  • Posts: 589
  • Joined: 11-February 10
  • Gender:Male
  • Location:Boston

Posted 09 November 2012 - 01:36 PM

quick draw Lemuel!
0

#7 User is offline   doesit 

  • New Member
  • Pip
  • Group: Members
  • Posts: 4
  • Joined: 06-November 12

Posted 09 November 2012 - 01:47 PM

Not quite fellas. I tried before with the single quote and with the double and single quote(from what the book is showing and what I posted there). One I use the double/single quote the code passes until line 32. However when I use the single quote what is logically correct and what you noticed as well....The code will pass everything untill it gets to line 31 of my code.
0

#8 User is offline   astonecipher 

  • New Member
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 20-November 12

Posted 27 November 2012 - 04:30 PM

Looking through your code, in the red font specifically. You have:


echo '<table>';
while ($row = mysqli_fetch_array($data)) {
// Display the score data
echo '<tr><td class="scoreinfo">';
echo '<span class="score">' . $row['score'] . '</span><br />';
echo '<strong>Name:</strong> ' . $row['name'] . '<br />';
echo '<strong>Date:</strong> ' . $row['date'] . '</td>';

if (is_file($row['screenshot']) && filesize($row["screenshot'])>0 {
echo '<td><img src="'.$row['screenshot'].'"alt="Score image"/></td></tr>';
}

else {

echo'<td><img src="unverified.gif"alt="Unverified score"/></td></tr>';
}
}
echo'</table>';




<table> starts the table </table> closes it.

<tr> for table row </tr>

and <td> for the cell contents </td>

right?

Well, your echo statement from you close the table has a table row end tag without a start tag. So, that would cause an error.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users