Jump to content
Larry Ullman's Book Forums

Successful Mysql Connection, But I Can'T Access My Database


Recommended Posts

Last week I purchased  Mr. Ullman's "PHP and MySQL for Dynamic Web Sites" 4 edition. I have never tried working with php, nor mysql before.  From my home, I have a stand-alone computer acting as a server. I am  running Microsoft 2008 server on this computer.  I also have Apache 2.2 running with no problems.  I have installed "MySQL 5.6, and PHP 5.3.27, and again, no problems.

 

I have a static ip address, and am hosting a small experimental website.  I made the site with Dreamweaver.

 

Wanting to try some script, I skipped ahead to Chapter 5, and experimented with some of the script.  Using the "MYSQL Command line" lessons, I created a Database named "Bfdata."  I then created a Table named "Members," with only two columns.  The first column is named "username," and the second column is named "password."

 

I then inserted 3 different users with the name of 1, 2, and 3 (those are the actual names I created for experimental sake)  I gave each a password of xyzzyx123321 (that's the actual password for each one I created, also for experimental sake)

 

I then went ahead to Chapter 9, and tried out the script 9.2 called "mysqli_connect.php"  Try as I may, I couldn't get the file to communicate with the "mysql server."  According to Mr. Ullman's tips, my php version might not support the "mysqli" function. 

 

So I searched the web and found a configuration that works good. The script reads as follows:

<?php
$link = mysql_connect('localhost' ,'john' , 'xyzzyx');
if (!$link) {
die('could not connect: ' . mysql_error());
}
echo 'connected successfully';
?>

 

My question is this:  Obviously with the above script, I'm connecting to the Mysql server, but what I want the script to do, is not only successfully connect, but to then access the table called "members,"  and check for the  "username" called 1 and check 1's password which is "xyzzyx123321," or "username 2, or 3 which also have the same password. Once the user name and password are successful , I'd like the script to pass the successful user on to a html page called upload that I made. 

 

Would  someone write that script and either post it, or send it to my johninbellingham@hotmail.com email address.

 

Thank you much,

johnjwe

Link to comment
Share on other sites

Greetings, upon seeing whom the reply from my question came from, I'm assuming it's "Larry," the author of my book.  Larry, your answer to my question seems somewhat condensending.  You say "If you read the book, all the information you need is there."  A couple of thoughts come to my mind about your answer. First of all, I'm looking at my Barnes and Noble receipt for the purchase of your book. Tax and all, it came to $48.90.  Secondly, I am a teacher of Microsoft Word, and Microsoft Excel, and teach 27 High school girls every week in a private Catholic high school. My first thought is that I am a paid customer of your product, and would expect if an Author of any book that offers free scripts to download, and allow readers to email him/her, they would gladly offer some help.  Your reply seems to infer that if I "read the book," I could gleen from the book, the answer to my question.  Are you saying "read the book" in the past tense, as if I read the book already, or "read the book" in the future?  I mention above that I am a teacher.  Good grief, many a times I have willingly stayed behind the normal class times to help my students; expecting NOTHING in return.  In fact, I feel honored to work "one-on-one" with my students.  As I mentioned in my initial question, I went from chapter 5 to chapter 9 skipping in between, because of time constraints.  By doing that, I can practice an idea here, and an idea there, without first having to read your book from beginning to end, before understanding the entirety of your book. I would think that you could have simply pointed to a particular page in your book, that should seemingly answer my question.  Is it so hard to offer a sample script that I can simply replace key wording with my wording to accommondate  for me the answer to my initial question. I LOVE teaching, and yes, I get paid for doing such, but I also do a lot of instructing for free. To me, there is NOTHING more rewarding than "going the extra mile," and hearing a simple "Thank you, that helped me a lot."  So now, I would suspect that I should say to you," gee, I'm sorry to have asked the question?"

 

Regards,

Johnjwe

Link to comment
Share on other sites

Hello Johnjwe. My apologies. It was not my intention to offend. I most certainly run these forums (at my own cost of time and money; not something many writers do) in order to help. 

 

I really don't like threads like this, and bailed on replying once already, but I'm going to reply anyway, although I expect my answer will only annoy you more...

 

No offense is intended, but your question struck me as lazy. You already have the book. The specific example you're looking for is most definitely covered in the book. My point is that if you read the book you already bought, you'll learn how to do this specific thing and you'll learn PHP & MySQL web development in general, which I assume is why you bought the book. 

 

And, for the record, you didn't ask for help, or where in the book that solution is, but rather that "someone write that script" and post it or email it to you. Had you asked for help or guidance, I would have provided help or guidance. Had you asked "Where in the book can I learn X?", I could have answered that. But you asked for other people to do the work for you (for free) and send it to you. 

 

You repeatedly point out that you're a teacher. How would you feel if one of your students emailed you and asked you to create a spreadsheet for them that does X, Y, and Z? They're taking the class to learn, they have the book, and yet....

 

Now maybe the difference is that that interaction would be relatively in person, and this one is online, and it's so much easier to offend online. In any case...

 

So I'm going to go ahead and apologize again, both for my initial reply (which, in hindsight, I still wouldn't change) and for this reply (which I also wouldn't change, but I imagine will offend you again). You and I obviously have different viewpoints as to what has transpired here. 

 

I imagine that after this interaction, you'll be done with me and my book. If not, and if you need help, I (and others) are most willing to offer that (for free). If so, then I wish you luck with your future endeavors and hope you find a book and writer more to your liking.

Link to comment
Share on other sites

Greetings again, Larry.  After reading your last reply to my comments, I understand what you were trying to convey to me about learning from the book, rather than asking for a free written script.  No apologies are needed or expected. In fact, my apologies to you for showing my frustration with trying to understand everything so quickly, instead of leaning on the time honored lesson of "patience."  And no, I won't be returning the book, or getting rid of it.  It's a fascinating book, and because of that, I find myself wanting to try everything all at once; and that was and is my weakness.  In the future, I will simply point to something particular from the book that might leave me pondering, and in turn, I'll post such in the forumn. Thanks for the admonishment, and your words are well spoken. 

 

Cheers,

johnjwe

Link to comment
Share on other sites

 Share

×
×
  • Create New...