Jump to content
Larry Ullman's Book Forums

Lou

Members
  • Posts

    97
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Lou

  1. Why would a web host offer PHP 5+ but not the mysqli functions? I thought that if PHP 5 was available, the mysqli extension would be too.
  2. Mysqli is not enabled on your remote host. If you search the phpinfo.php page, you won't see it. You'll only see mysql. Get your web host to enable mysqli or use the older mysql functions, detailed in Larry's PHP for the Web book.
  3. Here's the answer. Mysqli is not enabled on your remote server. That's why mysqli_connect() is undefined. Looking at the phpinfo script, mysqli does not show up. Only mysql.
  4. If you're testing your scripts on a real host, your DB_HOST is not localhost. Maybe it is, I don't know, I don't test my sites on real hosts right now. Only on my own development box. Also, are you sure your database name is sitename?
  5. 1. What version of PHP are you using? If you're using PHP 4 you can't use the mysqli functions. But since you're on a Windows 7 laptop, I don't think you'd be using PHP 4. 2. Can you sign into phpMyAdmin with the username and password you say you checked and are correct? 3. Run the mysqli_connect.php script by itself and see if you can connect. If it's stored in the includes folder, just type the URL out, ending with the mysqli_connect.php script. For example... http://localhost/sitename/includes/mysqli_connect.php
  6. Well, if your mysqli_connect.php file is stored inside the server root, inside the includes directory http://localhost/name_of_site/includes/mysqli_connect.php Make sure you have a working connection before you try to do more complicated coding and registration.
  7. Just run that mysqli_connect script by itself and see if you can connect. If you can't connect, your password or database name is wrong, or you don't have access to mysqli function.
  8. You need to actually execute the query. $insert = mysqli_query($dbc, $query); Your query is not correct though. Follow the previous person's advice and fix that query. I like to run my queries through the mysql monitor or phpmyadmin before trying it in php code. That may help you out. You also don't have to run that mysqli_select_db function, you already selected the database in your mysqli_connect function.
  9. I just wanted to get some work in using another language other than PHP. I thought you could connect to the DB using Perl, then still run queries with PHP. Haha. I'll learn Perl another time.
  10. Larry, I'm more than half way done with this book. After initial problems (mainly because I haven't used DOS style commands in awhile) I'm really enjoying this edition. I had no idea you could connect to MySql with Perl or Java. Even though I'm not going to really use these languages, I'm giving it a shot. One question -- Can you use Perl to connect to the database, but then use PHP to do everything else? Do you ever use Perl/Java for connecting, or do you mainly use PHP? Thanks again.
  11. the code on page 43 to change the root password does not seem to work anymore. Probably because the book is old. But... You have listed to change the root password via mysqladmin... bin\mysqladmin -u root password 'thenewpassword' The quotes cause a problem when creating the new password, as single quotes aren't trimmed, so your new password will include the single quotes This works bin\mysqladmin -u root -p password thenewpassword
  12. thanks Paul... I've been using PHPMyAdmin for about a year, but to learn SQL better, I've been trying to use the command line for many things. I'm actually connecting MySQL through PDO (upgraded from mysqli procedural) but I just couldn't figure out what was going on in the command line client. When you put it the way you did, that -u username is not SQL, it makes perfect sense. I was just assuming that the command line client would work the same way as all the examples in Larry's 2nd edition, and the 5 other MySQL books I have. This leads me to another question. When you start the command line client, how do you start it with another user other than root, or is that not possible? Thanks very much for your clear explanation previously!
  13. I can get in and change the user if I use cmd on windows 7. I can sign in as root, larry, basic, all of my users. However when I use the mysql command line client (start/all programs/zend server/mysql server 5.1/command line client) I simply cannot change users and it logs me in as root automatically, and when i enter the SQL to change the user, I get a syntax error. It seems that the mysql command line logs me in as root, and there's no way i can change users because i can't get back to the bin directory. When I use CMD, when i enter exit i am taken back to bin, where i can change users to root or one of the basic users i created.... anyone have any ideas?
  14. I have also updated my pdoconnect file to use the larry user that has select, update, delete, insert privileges on the larry database, and my localhost website still works (no access denied error). i can see this user when using phpmyadmin. larry/localhost. so what's up with my mysql monitor?
  15. still doesn't work. says: you have an error in your sql syntax... check the manual near 'mysql -u larry -p' at line 1. no matter what i do, i get this error. i created another user in phpmyadmin that has select, insert, update, and delete privileges on a certain database, say... larry. in the mysql monitor, before i try to change the user to larry, i make sure to show databases, and then use the larry database. any attempt to then change the user to the one i created results in this syntax error in the mysql monitor.
  16. the command: mysql -u username -p -h hostname never works. i always get a syntax error at the mysql monitor screen. why? say i have a user larry with password ullman on localhost at the mysql> mysql -u larry -p -h localhost; i get a syntax error 1064 (42000)... i'm at my wits end i don't get access denied... i get a syntax error!
  17. Pinning the icon to the taskbar just means that the icon to start the program is always there at the bottom of the desktop instead of going through Start/Programs. Another question... how do I login as a different user with the MySQL monitor? When I start it up, I can only enter the root password. I've set up the root user and the louis user through phpmyadmin. the louis user can only insert, update, select, and delete. i'd like to sign in as this user through mysql monitor, but don't see how to do it. using commands like -u louis -p -h localhost; does nothing. I'm completely confused. Do I have to change directories as it mentions in your book? I don't think so, because the top of the mysql monitor says it's already in the properl directory that mysql.exe is located.
  18. I've been experiencing some kind of bug with the MySQL monitor. I'm using Zend Community Server on Windows 7. PHP 5.35, MySQL 5.1.50. It seems that when I open the MySQL monitor, sign in as root, then pin the icon to my taskbar, if I ever exit the MySQL program with the exit command, when I click the taskbar icon again to open it, I'm still signed in, but as "odbc@localhost" and lose access to my databases. There's no way to sign out from this, either. Has anyone experienced this or know why it happens? I usually use PHPMyAdmin, but I'm learning to type all my commands in as well.
  19. I have started using Zend Server on Windows 7 and can send mail by just changing the SMTP line in php.ini to my ISP and using a valid email in the headers. I could never get the mail to work when using Linux (Ubuntu) and xampp.
  20. Stuart, your way works. I think i either forgot date() or instead of m I used M. So now we have two ways to make it work. Thank you both for your help.
  21. Hi Stuart. Yes, I used the date() function. I still couldn't get it to work. I'm sure there's a way to do it with that method though, I'll try your suggestion. But, I have gotten it to work by using some SQL functions. This works. $select_poll = "SELECT P.poll_id, P.question, A.answer_id, A.answer FROM poll_questions P INNER JOIN poll_answers A ON p.poll_id = A.poll_id WHERE date = (SELECT DATE_FORMAT(NOW() ,'%Y-%m-01'))"; Each poll question has a date column and I store the first date of the month in it... 2011/08/01, 2011/09/01, 2011/10/01. When the new month starts, the new poll and answers are shown.
  22. I have started to use PDO with the MySQL database for all of my inserts, updates, selects. Would that make a difference? I really need more work on my MySQL/MySQL skills. I had to take a break from this, my head was starting to spin.
  23. I've almost completed my poll item, but I'm struggling putting the finishing touches on it. Basically, I'm storing polls, answers, and votes in MySQL. The polls table has the poll_id, question, and date. The answers table has the answer_id, poll_id, answer, and votes. I have everything automated except when to show a particular poll. During August 2011 I want to show one poll along with it's question and answer choices. During September 2011, another. In the polls table I have a column called date that is type date. It stores dates in the format 2011-08-01 (year-month-day). I thought about making a variable that stores the current date in the same format. However when I put this variable in my query (since the variable will always change based on the current date) I get errors because the query expects the date string to be '2011-08-01', not 2011-08-01, without the quotes. I store every date as Year-Month-FirstDayofMonth... 2011-08-01 for August's poll... 2011-09-01 for September's poll I store the current date (2011-08) for Year-Month plus '01' for the first day of the month like this: $current_poll = ('Y' . "-" . 'm' . "-" . '01'); However when I put $current_poll in the query I always get errors because it expect the string to be surrounded in quotes. Here's my working query with the date hard coded. $select_poll = "SELECT P.poll_id, P.question, A.answer_id, A.answer FROM poll_questions P INNER JOIN poll_answers A ON p.poll_id = A.poll_id WHERE P.date = '2011-08-01'"; I want the date to be automated so when it's September 1, the poll with the date 2011-09-01 shows. So I'm stuck... Is there an easier way to do this?
  24. Can't you just put a regular expression in a variable and check each input for that? $naughty = '/Content-Type:|Bcc:|Cc:/i'; //when checking user input if (preg_match($naughty, $user_input)){ error['input_name'] = 'Naughty...'; } else { $input = true; }
  25. Thanks for your help, both of you. Everything is running smoothly when using sessions for the captcha and regular expressions for making sure no one uses my contact form as a spam relay. It was really fun drawing my own captcha with the gd library. I can't believe some of the things I'm doing after studying Larry's (and other author's) books for so long.
×
×
  • Create New...