<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
	<title><![CDATA[Head First PHP & MySQL]]></title>
	<description><![CDATA[O'Reilly's Head First PHP & MySQL book forum]]></description>
	<link>http://forums.oreilly.com/index.php</link>
	<pubDate>Fri, 20 Nov 2009 15:04:24 -0500</pubDate>
	<ttl>120</ttl>
	<image>
		<title><![CDATA[Head First PHP & MySQL]]></title>
		<url>http://oreilly.com/catalog/covers/9780596006303_bkt.gif</url>
		<link>http://forums.oreilly.com/index.php</link>
	</image>
	<item>
		<title>Chapter 7 - Empty Upload Error On Editprofile.php</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5606</link>
		<description><![CDATA[Hello, <br /> I found an error and needs simple fixing. I download chapter 7 and put it to a test.<br />I created a Mismatch account, logged in, went to edit profile, filled out everything, uploaded a small photo, clicked submit and everything was fine. Then I went back to edit my profile again, leaving all the information the same except my name, and when I click submit, I get the following error:<br /><br />Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /home/rpse/public_html/editprofile.php on line 52<br /><br />--------------------------Here is the code on that line------------------<br />LINE 52 STARTS AT  list($new_picture_width, $new_picture_height) <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&nbsp;&nbsp;&nbsp;&nbsp;$old_picture = mysqli_real_escape_string&#40;$dbc, trim&#40;$_POST&#91;'old_picture'&#93;&#41;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;$new_picture = mysqli_real_escape_string&#40;$dbc, trim&#40;$_FILES&#91;'new_picture'&#93;&#91;'name'&#93;&#41;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;$new_picture_type = $_FILES&#91;'new_picture'&#93;&#91;'type'&#93;;<br />&nbsp;&nbsp;&nbsp;&nbsp;$new_picture_size = $_FILES&#91;'new_picture'&#93;&#91;'size'&#93;; <br />&nbsp;&nbsp;&nbsp;&nbsp;list&#40;$new_picture_width, $new_picture_height&#41; = getimagesize&#40;$_FILES&#91;'new_picture'&#93;&#91;'tmp_name'&#93;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;$error = false;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;// Validate and move the uploaded picture file, if necessary<br />&nbsp;&nbsp;&nbsp;&nbsp;if &#40;!empty&#40;$new_picture&#41;&#41; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;&#40;&#40;$new_picture_type == 'image/gif'&#41; || &#40;$new_picture_type == 'image/jpeg'&#41; || &#40;$new_picture_type == 'image/pjpeg'&#41; ||<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#40;$new_picture_type == 'image/png'&#41;&#41; && &#40;$new_picture_size &#62; 0&#41; && &#40;$new_picture_size &#60;= MM_MAXFILESIZE&#41; &&<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#40;$new_picture_width &#60;= MM_MAXIMGWIDTH&#41; && &#40;$new_picture_height &#60;= MM_MAXIMGHEIGHT&#41;&#41; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;$_FILES&#91;'file'&#93;&#91;'error'&#93; == 0&#41; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Move the file to the target upload folder<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$target = MM_UPLOADPATH . basename&#40;$new_picture&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;move_uploaded_file&#40;$_FILES&#91;'new_picture'&#93;&#91;'tmp_name'&#93;, $target&#41;&#41; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// The new picture file move was successful, now make sure any old picture is deleted<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if &#40;!empty&#40;$old_picture&#41; && &#40;$old_picture != $new_picture&#41;&#41; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@unlink&#40;MM_UPLOADPATH . $old_picture&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// The new picture file move failed, so delete the temporary file and set the error flag<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@unlink&#40;$_FILES&#91;'new_picture'&#93;&#91;'tmp_name'&#93;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$error = true;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo '&#60;p class=&#34;error&#34;&#62;Sorry, there was a problem uploading your picture.&#60;/p&#62;';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// The new picture file is not valid, so delete the temporary file and set the error flag<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@unlink&#40;$_FILES&#91;'new_picture'&#93;&#91;'tmp_name'&#93;&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$error = true;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo '&#60;p class=&#34;error&#34;&#62;Your picture must be a GIF, JPEG, or PNG image file no greater than ' . &#40;MM_MAXFILESIZE / 1024&#41; .<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' KB and ' . MM_MAXIMGWIDTH . 'x' . MM_MAXIMGHEIGHT . ' pixels in size.&#60;/p&#62;';<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<!--c2--></div><!--ec2--><br /><br />Any Suggestions of how to fix this issue?]]></description>
		<pubDate>Thu, 19 Nov 2009 13:54:07 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5606</guid>
	</item>
	<item>
		<title>Chapter 7.5 Code Download</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5599</link>
		<description><![CDATA[Hi there,<br /><br />First of all I want to thank the authors for a great book that has helped me alot in learning php and javascript (think that was also written by Michael Morrison).<br />I love the head first way of teaching/learning <img src="http://forums.oreilly.com/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />There's just 1 small remark I want to say about the code download of chapter 7.5: eliminating duplicate code.<br />The initial files in the download don't look like the screenshots in the book, the menu has changed and is now on every page and there is also a footer on every page. <br />The code downloads initial files don't have these changes.<br /><br />PS: Yes I realise that editing the files yourself so it matches the screenshots in the book isn't a big deal and you can do it yourself in 10 minutes or less  <img src="http://forums.oreilly.com/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /><br /><br />Kind regards,<br />Steven Vandemoortele]]></description>
		<pubDate>Thu, 19 Nov 2009 03:19:24 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5599</guid>
	</item>
	<item>
		<title>Chapter 5 Page 251</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5596</link>
		<description><![CDATA[I am not sure exactly what is happening.  I have been working on getting the image to transfer to the appropriate folder and didn't notice that I am not writing to the database.  My code to add a score is as follows:<br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;<br />&lt;head&gt;<br />  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />  &lt;title&gt;Guitar Wars - Add Your High Score&lt;/title&gt;<br />  &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />  &lt;h2&gt;Guitar Wars - Add Your High Score&lt;/h2&gt;<br /><br />&lt;?php<br />require_once('appvars.php');<br />require_once('connectvars.php');<br /><br />  if (isset($_POST['submit'])) {<br />    // Grab the score data from the POST<br />    $name = $_POST['name'];<br />    $score = $_POST['score'];<br />    $screenshot= $_FILES['screenshot']['name'];<br />	$screenshotsize= $_FILES['screenshot']['size'];<br /><br />    if (!empty($name) && !empty($score) && !empty($screenshot)) {<br />    <br />      //Move file to GW_Upload path<br />      $target = GW_UPLOADPATH . $screenshot;<br />      <br />     <br />      if (move_uploaded_file($_FILES['screenshot']['tmp_name'], $target)) {<br />      //echo "$target";<br />      // Connect to the database<br />  	  $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);<br /><br />      // Write the data to the database<br />      $query = "INSERT INTO guitarwars VALUES (0, NOW(), '$name', '$score', '$screenshot')";<br />      mysqli_query($dbc, $query);<br /><br /><br />      // Confirm success with the user<br />      echo '&lt;p&gt;Thanks for adding your new high score!&lt;/p&gt;';<br />      echo '&lt;p&gt;&lt;strong&gt;Name:&lt;/strong&gt; ' . $name . '&lt;br /&gt;';<br />      echo '&lt;strong&gt;Score:&lt;/strong&gt; ' . $score . '&lt;/p&gt;';<br />      echo '&lt;img src="' . GW_DisplayPATH . $screenshot . '" /&gt;';<br />      echo '&lt;p&gt;&lt;a href="index.php"&gt;&lt;&lt; Back to high scores&lt;/a&gt;&lt;/p&gt;';<br /><br />      // Clear the score data to clear the form<br />                $name = "";<br />                $score = "";<br />                $screenshot = "";<br />    <br />                mysqli_close($dbc);<br />      <br />    }<br />    else {<br />      echo '&lt;p class="error"&gt;Please enter all of the information to add your high score.&lt;/p&gt;';<br />    }<br />    }<br />  }<br />?&gt;<br /><br />  &lt;hr /&gt;<br />  &lt;form enctype="multipart/form-data" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;<br />  	&lt;input type="hidden" name="MAX_FILE_SIZE" value="999999"&gt;<br />    &lt;label for="name"&gt;Name:&lt;/label&gt;<br />    &lt;input type="text" id="name" name="name" value="&lt;?php if (!empty($name)) echo $name; ?&gt;" /&gt;&lt;br /&gt;<br />    &lt;label for="score"&gt;Score:&lt;/label&gt;<br />    &lt;input type="text" id="score" name="score" value="&lt;?php if (!empty($score)) echo $score; ?&gt;" /&gt;<br />    &lt;label for="screenshot"&gt; Screenshot&lt;/label&gt;<br />    &lt;input type="file" id="screenshot" name="screenshot" /&gt;<br />    &lt;hr /&gt;<br />    &lt;input type="submit" value="Add" name="submit" /&gt;<br />  &lt;/form&gt;<br />&lt;/body&gt; <br />&lt;/html&gt;<br /></div><br /><br />Here is the connect vars code<br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>&lt;?php<br />//Define Database connection constants<br />define('DB_HOST', 'localhost');<br />define('DB_USER', 'root');<br />define('DB_PASSWORD', 'root');<br />define('DB_NAME', 'gwdb');<br />?&gt;</div><br /><br />Strangely even when I place database code directly inline as opposed to calling it with an external script setting the variables it is not writting to the database.  Further more the code executes without throwing any errors.  It just doesn't write to the database.<br /><br />Any clues out there?]]></description>
		<pubDate>Wed, 18 Nov 2009 22:47:57 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5596</guid>
	</item>
	<item>
		<title>Chapter 8, Page 490</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5588</link>
		<description><![CDATA[Hello:<br /><br />I have a question regarding the 3rd line of coding on page 490 which is:<br /><br />$score += 1;<br /><br />This doesn't seem correct.  Should this line be:<br /><br />$score++;<br /><br />Or should it be something else?<br /><br />This same coding is listed on page 492 and is in the downloaded coding file (mymismatch.php).<br /><br /><br />Thank you.]]></description>
		<pubDate>Tue, 17 Nov 2009 18:49:33 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5588</guid>
	</item>
	<item>
		<title>Chapter 4: Sendemail.php Script Not Sticky.</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5552</link>
		<description><![CDATA[Hello all, <br />             I've been working away at the sendemail.php script from chapter 4 and upon pressing the "submit" button, nothing happens, no error messages, nothing. <br />Please help me?<br /><br />Below is my full script (personal info omitted) :<br /><br />&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br />  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;<br />&lt;head&gt;<br />  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;<br />  &lt;title&gt;Make Me Elvis - Send Email&lt;/title&gt;<br />  &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />  &lt;img id="elvis" src="blankface.jpg" width="161" height="350" alt="" style="float:right" /&gt;<br />  &lt;img name="elvislogo" src="elvislogo.gif" width="229" height="32" border="0" alt="Make Me Elvis" /&gt;<br />  &lt;p&gt;&lt;strong&gt;Private:&lt;/strong&gt; For Admin's use ONLY&lt;br /&gt;<br />  Write and send an email to mailing list members.&lt;/p&gt;<br />  <br />&lt;?php <br />   if (isset($_POST['submit'])) {<br />     $from = ***********@hotmail.co.uk';<br />     $subject = $_POST ['subject'];<br />     $text = $_POST ['elvismail'];<br />     $output_form = false;<br />  <br />     if (empty($subject) && empty($text)) {<br />       //I know both fields are empty<br />       echo 'You forgot the email subject and body text.&lt;br /&gt;';<br />       $output_form = true;<br />     }<br />  <br />     if (empty($subject) && (!empty($text))) {<br />       //I know just the text field is empty<br />       echo 'You forgot the email subject.&lt;br /&gt;';<br />       $output_form = true;<br />     }<br />  <br />     if ((!empty($subject)) && empty($text)) {<br />       //I know just the subject field is empty<br />       echo 'You forgot the email body text.&lt;br /&gt;';<br />       $output_form = true;<br />     }<br />   }<br />   else {<br />      $output_form = true;<br />     }<br />   <br />     if ((!empty($subject)) && (!empty($text))) {<br />       //Both fields are filled, send the email<br />      $dbc = mysqli_connect(***********', *********, *******', ***********')<br />        or die('Error connecting to MySQL server.');<br />  <br />      $query = "SELECT * FROM email_list";<br />      $result = mysqli_query($dbc, $query)<br />        or die('Error querying database.');<br />  <br />      while ($row = mysqli_fetch_array($result)) {<br />        $to = $row['email'];<br />        $first_name = $row['first_name'];<br />        $last_name = $row['last_name'];<br />        $msg = "Dear $first_name $last_name,&#092;n$text";<br />        mail($to, $subject, $msg, 'From: ' . $from);<br />        echo 'Email sent to: ' . $to . '&lt;br /&gt;';<br />      } <br />    <br />    mysqli_close($dbc);  <br />  }<br />    <br />  if ($output_form) {<br />?&gt;<br /><br />  &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;<br />    &lt;label for="subject"&gt;Subject of email:&lt;/label&gt;&lt;br /&gt;<br />    &lt;input id="subject" name="subject" type="text" value="&lt;?php echo $subject; ?&gt;" size="30" /&gt;&lt;br /&gt;<br />    &lt;label for="elvismail"&gt;Body of email:&lt;/label&gt;&lt;br /&gt;<br />    &lt;textarea id="elvismail" name="elvismail" rows="8" cols="40"&gt;&lt;?php echo $text; ?&gt;&lt;/textarea&gt;&lt;br /&gt;<br />    &lt;input type="submit" name="Submit" value="Submit" /&gt;<br />  &lt;/form&gt;<br />  <br />&lt;?php <br />  }<br />?&gt;<br /><br />&lt;/body&gt;<br />&lt;/html&gt;]]></description>
		<pubDate>Wed, 11 Nov 2009 11:17:02 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5552</guid>
	</item>
	<item>
		<title>Page 264 - Loop Through Array In Index Php Question</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5550</link>
		<description><![CDATA[<img src="http://forums.oreilly.com/style_emoticons/default/dry.gif" style="vertical-align:middle" emoid="&lt;_&lt;" border="0" alt="dry.gif" /> <br />The following code has me questioning the need for the incremental on $i at the end of the code, $i++;<br /><br />As $i is assigned a value of 0 and then used in the conditional for the following IF statement IF ($i == 0) { do this ....  Else { do this <br /><br />As far as I understand $i will never loop as the condition is met on the first pass, so we can display a high-score of 0, and the value of $i is reset every time the script is run.<br /><br />So why increment the counter ?<br /><br />/ Retrieve the score data from MySQL<br />  $query = "SELECT * FROM guitarwars ORDER by score desc, date asc";<br />  $data = mysqli_query($dbc, $query);<br /><br />   // Loop through the array of score data, formatting it as HTML <br />  echo '&lt;table&gt;';<br /> <b> $i = 0;  </b><br />  while ($row = mysqli_fetch_array($data)) { <br />    // Display the score data<br />    <b>if ($i == 0) {</b><br />      echo '&lt;tr&gt;&lt;td colspan="2" class="topscoreheader"&gt;Top Score: ' . $row['score'] . '&lt;/td&gt;&lt;/tr&gt;';<br />    }<br />    echo '&lt;tr&gt;&lt;td class="scoreinfo"&gt;';<br />    echo '&lt;span class="score"&gt;' . $row['score'] . '&lt;/span&gt;&lt;br /&gt;';<br />    echo '&lt;strong&gt;Name:&lt;/strong&gt; ' . $row['name'] . '&lt;br /&gt;';<br />    echo '&lt;strong&gt;Date:&lt;/strong&gt; ' . $row['date'] . '&lt;/td&gt;';<br />    if (is_file(IMG_PATH . $row['screenshot']) && filesize(IMG_PATH . $row['screenshot']) &gt; 0) {<br />      echo '&lt;td&gt;&lt;img src="' . IMG_PATH . $row['screenshot'] . '" alt="Score image" /&gt;&lt;/td&gt;&lt;/tr&gt;';<br />    }<br />  <b>  else {</b><br />      echo '&lt;td&gt;&lt;img src="' . IMG_PATH . 'unverified.gif' . '" alt="Unverified score" /&gt;&lt;/td&gt;&lt;/tr&gt;';<br />    }<br />  <b>  $i++; </b><br />}<br />echo '&lt;/table&gt;';<br />]]></description>
		<pubDate>Tue, 10 Nov 2009 23:10:45 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5550</guid>
	</item>
	<item>
		<title>Mysql Client (or Terminal) Not Functioning</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5549</link>
		<description><![CDATA[It's probably staring me in the face, but after devoting the bulk of my day trying to solve this problem from several angles, it's time to put the call out for advice.<br /><br />First, my system is Mac 2 x 2.8 GHz Quad-Core Intel Xeon, running 10.5.8<br /><br />After several false starts, I believe I've installed MySQL 5.1.40-community for Mac OS X. <br />(I'd tried installing a 5.0.87 version a bit earlier, but in working with it in terminal, I kept getting "No such file or directory" replies. So I disabled it using sudo rm /usr/local/mysql and then sudo rm -rf /Library/StartupItems/MySQLCOM/)<br /><br />Okay. Back to 5.1 and terminal<br /><br />When I entered the command cd /usr/local/mysql, it replied with:<br />(name of computer):mysql (name of user)$<br />to which I entered mysql, as suggested often works on page 64.<br /><br />Instead of working, it returned -bash: mysql; command not found.<br /><br />However, when I entered ./bin/mysqlshow -u root<br />It returned with a short table of databases.<br /><br />Feeling confident, I typed CREATE DATABASE aliendatabase;<br />It replied  -bash: CREATE: command not found<br /><br />Since I couldn't find any other suggestions in Head First, I went to Visual QuickStart. I suggested that to use the mysql client, that I enter ./bin/mysql -u root -p<br />I did that, and it asked for my password. I entered my root password. <br /><br />It then returned ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)<br /><br />I tried entering a slightly different code, ./bin/mysql - root -p<br /><br />To which it returned with a long text beginning:<br />./bin/mysql  Ver 14.14 Distrib 5.1.40, for apple-darwin9.5.0 (i386) using readline 5.1<br />Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.<br />This software comes with ABSOLUTELY NO WARRANTY. This is free software,<br />and you are welcome to modify and redistribute it under the GPL license<br />Usage: ./bin/mysql [OPTIONS] [database]<br />  -?, --help          Display this help and exit.<br />  -I, --help          Synonym for -?<br /><br />I have yet to see "mysql&gt;" that would enable me to start building my database. <br />According to the system preferences screen, the MySQL Server Instance is running.<br /><br />(And yes, the system preferences has unexpectedly quit several times today, giving the MySQL preference as likely the origin of its problems.)<br /><br />The above is a very abbreviated version of my attempts, but you get the gist. <br /><br />Thanks!]]></description>
		<pubDate>Tue, 10 Nov 2009 18:30:10 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5549</guid>
	</item>
	<item>
		<title>Chapter 2 - Test Drive (page 89)</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5536</link>
		<description><![CDATA[I've been getting this error on my browser and I'm not too sure of how to fix this.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Warning&#58; mysqli_connect&#40;&#41; &#91;function.mysqli-connect&#93;&#58; &#40;HY000/2005&#41;&#58; Unknown MySQL server host 'localhost&#58;/tmp/mysql.sock' &#40;1&#41; in /Users/alavador/Sites/004_HF_PHP&MYSQL/ch02/initial/aliens/report.php on line 24<br />Error connecting to MySQL server.<!--c2--></div><!--ec2--><br /><br />i havent changed anything from the code that was instructed in the book but the my own MySQL information.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&#60;html&#62;<br /><br />&#60;head&#62;<br />&nbsp;&nbsp;<br />&nbsp;&nbsp;&#60;title&#62;Aliens Abducted Me - Report an Abduction&#60;/title&#62;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&#60;/head&#62;<br /><br />&#60;body&#62;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&#60;h2&#62;Aliens Abducted Me - Report an Abduction&#60;/h2&#62;<br /><br />&#60;?php<br />$name = $_POST&#91;'firstname'&#93; . ' ' . $_POST&#91;'lastname'&#93;;<br />$when_it_happen = $_POST&#91;'whenithappened'&#93;;<br />$how_long = $_POST&#91;'howlong'&#93;;<br />$how_many = $_POST&#91;'howmany'&#93;;<br />$alien_description = $_POST&#91;'aliendescription'&#93;;<br />$what_they_did = $_POST&#91;'whattheydid'&#93;;<br />$fang_spotted = $_POST&#91;'fangspotted'&#93;;<br />$email = $_POST&#91;'email'&#93;;<br />$other = $_POST&#91;'other'&#93;;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;$dbc = mysqli_connect &#40;'localhost&#58;/tmp/mysql.sock', 'root', '', 'aliendatabase' &#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;or die &#40;'Error connecting to MySQL server.'&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;$query = &#34;INSERT INTO aliens_abduction &#40;first_name, last_name, &#34; .<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;when_it_happened, how_long, how_many, alien_description, &#34;.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;what_they_did, fang_spotted, other, email&#41;&nbsp;&nbsp;&#34; .<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;VALUES &#40;'Sally, 'Jones', '3 days ago', '1 day ', 'four', &#34; .<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;'green with six tentacles', 'We just talked and played with a dog', &#34; .&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;'yes', 'I may have seen your dog. Contact me.', &#34; .&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#34;'sally@gregs-list.net'&#34;&#59;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;$result = mysqli_query&#40;$dbc, $query&#41;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or die&#40;'Error querying database.'&#41;;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;mysqli_close&#40;$dbc&#41;;<br /><br />echo 'Thanks for submitting to the form.&#60;br /&#62;';<br />echo 'You were abducted ' . $when_it_happen;<br />echo ' and were gone for ' . $how_long . '&#60;br /&#62;';<br />echo 'Number of aliens&#58; '.$how_many .'&#60;br /&#62;';<br />echo 'Describe them&#58; ' . $alien_description . '&#60;br /&#62;';<br />echo 'The aliens did this&#58; ' . $what_they_did . '&#60;br /&#62;'; <br />echo 'Was Fang there? ' . $fang_spotted . '&#60;br /&#62;';<br />echo 'Other comments&#58; ' . $other . '&#60;br /&#62;'; <br />echo 'Your email address is ' . $email;<br />?&#62;<br /><br /><br />&#60;/body&#62;<br /><br />&#60;/html&#62;<!--c2--></div><!--ec2--><br /><br />i'm wondering if there is something up with my phpmyadmin settings?<br />i'm pretty new at this and much help would be appreciated thanks <img src="http://forums.oreilly.com/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />]]></description>
		<pubDate>Sat, 07 Nov 2009 21:24:41 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5536</guid>
	</item>
	<item>
		<title>Form Validation Code</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5523</link>
		<description><![CDATA[On page 295 of book , Would it be more descriptive and correct to write IF ($output_form = true) {<br />instead of just  If ($output_form) { <br /><br />To display the form as shown below<br /><br />.... // code above to validate and send email.<br />    echo 'Email sent to: ' . $to . '&lt;br /&gt;';<br />    }<br />	mysqli_close($dbc); // close database link<br /> }<br />	<b>if ($output_form = true) </b> {  //  code to be executed if condition is true;<br />?&gt;<br /> &lt;form method="post" action="sendemail.php"&gt;<br />    &lt;label for="subject"&gt;Subject of email:&lt;/label&gt;&lt;br /&gt;<br /><br />Or would this code create problems in more advanced coding structures. ?]]></description>
		<pubDate>Wed, 04 Nov 2009 18:53:34 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5523</guid>
	</item>
	<item>
		<title>Blank Php Page</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5516</link>
		<description><![CDATA[Hello - I am having the same problem with the code as I did on chapter one... I never solved it but thought I would move on... basically, the php page is returned blank, with no data going to the server. I thought it might be a powweb issue but they say php is working fine... please take a look at my code and let me know what I am doing wrong if you can. Thanks.<br /><br />&lt;html&gt;&lt;head&gt;&lt;title&gt;test&lt;/title&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;/head&gt;<br />&lt;body&gt;<br />&lt;?php<br /><br />$dbc = mysqli_connect('abelincolnstory.powwebmysql.com', 'smoramarco', 'password', 'elvis_store')<br />or die ('Error connecting to MySQL server.');<br /><br />$first_name = $_POST['firstname'];<br />$last_name = $_POST['lastname'];<br />$email = $_POST['email'];<br /><br />$query = "INSERT INTO email_list (first_name, last_name, email)" .<br />	"VALUES ('$first_name', '$last_name', '$email')";<br />	<br />mysqli_query($dbc, $query)<br />	or die('Error querying database.');<br />	<br />echo 'Customer added.';<br /><br />mysqli_close($dbc);<br /><br />?&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;]]></description>
		<pubDate>Tue, 03 Nov 2009 20:04:13 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5516</guid>
	</item>
	<item>
		<title>Chapter 5 - Index.php Not Displaying Images</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5507</link>
		<description><![CDATA[Hi everyone! This book is great but these Chapter 5 errors have SERIOUSLY slowed me down and are driving me insane. <br /><br />So I am using the final versions of the code provided by Head First... and with index.php when I upload the images, it will move images from the tmp folder to the images folder BUT it is not displaying the images. <br /><br />It will say 'unverified score' or 'verified score' (aka the 'alts') but there is nothing I can do to make the images show up. <br /><br />I've made the file permissions 777 and I've tried several little things with the code.. <br /><br />Please HELP! <img src="http://forums.oreilly.com/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />]]></description>
		<pubDate>Sun, 01 Nov 2009 21:58:48 -0500</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5507</guid>
	</item>
	<item>
		<title>Ch. 6 Authorize.php Script</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5498</link>
		<description><![CDATA[Hello all,<br /><br />Winding my way through the book, on or about pg 315 where we are to move the php script that uses headers for HTTP authentication from the beginning of admin.php and stick it in a separate include file called 'authorize.php', and put the relevant hooks via 'require_once()' in both 'admin.php' and 'removescore.php'.<br /><br />What works: <br /><br />The HTTP authentication header script in the beginning of admin.php works fine.  Just like it should.  But when I cut-n-paste that script into a new file called authorize.php, save that file, and put <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->&#60;?php<br />require_once&#40;'authorize.php'&#41;;<br />?&#62;<!--c2--></div><!--ec2--><br /><br />at the very beginning of admin.php, exactly where the previous script was 'cut' from... this is what I get instead of a log-in window:<br /><br /><!--quoteo--><div class='quotetop'>QUOTE </div><div class='quotemain'><!--quotec-->Warning: Cannot modify header information - headers already sent by (output started at E:&#092;xampplite&#092;htdocs&#092;guitarwars&#092;authorize.php:1) in E:&#092;xampplite&#092;htdocs&#092;guitarwars&#092;authorize.php on line 9<br /><br />Warning: Cannot modify header information - headers already sent by (output started at E:&#092;xampplite&#092;htdocs&#092;guitarwars&#092;authorize.php:1) in E:&#092;xampplite&#092;htdocs&#092;guitarwars&#092;authorize.php on line 10<br /><br />Guitar Wars<br />Sorry, you must enter a valid user name and password to access this page.<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />Lines 9 & 10 are the lines in authorize.php where it sends the headers.  Again, nothing has changed from before when it *did* work, except which file its stored in.  I've been looking at the final versions of admin.php and authorize.php from the code archive, but as of yet I can't seem to pin point where I went wrong.<br /><br />Any help or nudges in the right direction would be much appreciated.<br /><br />TIA,<br /><br />Monte]]></description>
		<pubDate>Fri, 30 Oct 2009 00:38:38 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5498</guid>
	</item>
	<item>
		<title>I Need Some Support For Chapter 9</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5496</link>
		<description><![CDATA[This may seem like an incredibly stupid question but I just don't get this.<br /><br />Where exactly are you supposed to put all the commands on page 514. Is all that code supposed to go in the query variable? And what variable are you supposed to use in mysqli_query?<br /><br />I tried looking for support in the final php script but it doesn't really help.<br /><br />Forgive me for asking something that's probably right in my face. Maybe someone can just post the code for that page?<br /><br />Thanks.]]></description>
		<pubDate>Thu, 29 Oct 2009 08:58:37 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5496</guid>
	</item>
	<item>
		<title>Chapter 1 Not Working</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5492</link>
		<description><![CDATA[Hello,<br /><br />I can't seem to get the report.php to work correctly, sending the info to the database and showing a successful report submission. Instead I get a blank php page (except for the html Thanks for submitting) and it doesn't get entered in the database. I have pasted the code below. Please tell me what I did wrong. Thank you!<br /><br />Steve<br /><br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;title&gt;Test&lt;/title&gt;<br />&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />Thanks for submitting<br /><br />&lt;?php<br />	$first_name = $_POST['firstname'];<br />	$last_name = $_POST['lastname'];<br />	$when_it_happened = $_POST['whenithappened'];<br />	$how_long = $_POST['howlong'];<br />	$how_many = $_POST['howmany'];<br />	$alien_description = $_POST['aliendescription'];<br />	$what_they_did = $_POST['whattheydid'];<br />	$fang_spotted = $_POST['fangspotted'];<br />	$email = $_POST['email'];<br />	$other = $_POST['other'];<br /><br />$dbc = mysqli_connect('abelincolnstory.powwebmysql.com', 'smoramarco', '*I omitted password for security*', 'aliendatabase')<br />	or die('Could not connect'); <br /><br />$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .<br />    "how_many, alien_description, what_they_did, fang_spotted, other, email) " .<br />	"VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many=', " .<br />	"$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";<br />	<br />$result = mysqli_query($dbc, $query)<br />  or die('Error querying database.');<br />  <br />	mysqli_close($dbc);<br /><br />	echo 'Thanks for submitting the form. &lt;br /&gt;';<br />	echo 'You were abducted ' . $when_it_happened;<br />	echo 'and were gone for ' . $how_long  . '&lt;br /&gt;';<br />	echo 'number of aliens: ' . $how_many  . '&lt;br /&gt;';<br />	echo 'Describe them: ' . $alien_description . '&lt;br /&gt;';<br />	echo 'The aliens did this ' . $what_they_did . '&lt;br /&gt;';<br />	echo 'Was Fang there? ' . $fang_spotted . '&lt;br /&gt;';<br />	echo 'Other comments: ' . $other . '&lt;br /&gt;';<br />	echo 'Your email address is ' . $email;<br /><br />?&gt; <br /><br />&lt;/body&gt;<br />&lt;/html&gt;<br />]]></description>
		<pubDate>Wed, 28 Oct 2009 19:50:58 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5492</guid>
	</item>
	<item>
		<title>Chapter 7 : Log In Problems</title>
		<link>http://forums.oreilly.com/index.php?showtopic=5480</link>
		<description><![CDATA[Hi guys, <br /><br /><br />This is the first post I'm making, and just to get it out of the way I appreciate whatever help you wish to give me at this ungodly hour (3:14a EST at the time) in advance. Thank you.<br /><br />Okay, now for the problem. I'm currently working on Chapter 7 with cookie powered logins. I got the sign up sheet to work with my current database and was easy enough because it was INPUTTING data on the user. The problem I've been having over the past week is getting that data BACK via login. I'll explain.<br /><br />I created my login page and I thought everything went well until I clicked the submit button and I got the error of not it being a valid login. I thought I misspelled it so I created a new user using the sign up sheet I had made earlier. User was put in the database, but that still didn't let me in. I played around the code a bit and broke it down to what could have caused the problem:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>   if (!empty($user_username) && !empty($user_password)) {<br />        // Look up the username and password in the database<br />        $query = "SELECT user_id, username FROM mismatch_user WHERE username = '$user_username' AND password = SHA('$user_password')";<br />        $data = mysqli_query($dbc, $query);<br /><br />        if (mysqli_num_rows($data) == 1) {<br />          // The log-in is OK so set the user ID and username session vars (and cookies), and redirect to the home page<br />          $row = mysqli_fetch_array($data);<br />          $_SESSION['user_id'] = $row['user_id'];<br />          $_SESSION['username'] = $row['username'];<br />          setcookie('user_id', $row['user_id'], time() + (60 * 60 * 24 * 30));    // expires in 30 days<br />          setcookie('username', $row['username'], time() + (60 * 60 * 24 * 30));  // expires in 30 days<br />          $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/index.php';<br />          header('Location: ' . $home_url);<br />        }<br />        else {<br />          // The username/password are incorrect so set an error message<br />          $error_msg = 'Sorry, you must enter a valid username and password to log in.';<br />        }<br />      }<br />     </div><br /><br />I turned the mysqli_num_rows to 0, and that basically lets everyone in. Not very secure, but close. To tell the truth, I still have no idea why it's blocking me out when code is saying "The username and password in this table is RIGHT THERE. They match.Let him in" But it doesn't, and I don't get it.<br /><br />And to add insult to injury, I decided to start from scratch and just take the code from the site (thanks!) and see if it'll make sense when done the right way. I uploaded the table to the database I'm working with, change the connectvar file so it'll connect and signup works... for the most part:<br /><br /><div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'>Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:&#092;wamp&#092;www&#092;Mismatch_2&#092;signup.php on line 29</div><br /><br />That shows up every time I sign up or fail to log in from Mismatch. I'm new to PHP, and even when I'm looking into the error I have no clue what that means. All I did was copy, paste, and change the database connection.<br /><br />I'm using IE and Firefox to see if there are any browser issues such as cookies being off. They're enabled for both so I'm officially out of ideas.<br /><br />Short version: I'm hopeless with log ins and I need help. They won't let me, you know, <i> log in.</i><br /><br />EDIT: Okay, so I sort of fixed the PHP error by adding in 'username' and 'password' to quickly sign up users on the sign up page. Still not able to log in.]]></description>
		<pubDate>Tue, 27 Oct 2009 03:34:27 -0400</pubDate>
		<guid>http://forums.oreilly.com/index.php?showtopic=5480</guid>
	</item>
</channel>
</rss>