Page 2 of 2

Posted: Fri Oct 21, 2005 7:30 pm
by Charles256
herm....guess mysql and mysqli do have differences;) i normally omit the connection. i say remove storing your connection in a variable and put it on it's own line and forget the connection in the query, just do the query:-D

Posted: Fri Oct 21, 2005 7:41 pm
by RobertGonzalez
Charles256 wrote:herm....guess mysql and mysqli do have differences;) i normally omit the connection. i say remove storing your connection in a variable and put it on it's own line and forget the connection in the query, just do the query:-D
Yeah, I usually use a DB class, similar to phpBB's Database Abstraction Layer, so using the connection link is done behind the scenes. But I agree, the PHP core developers seem to like to keep us developers guessing with their parameter arrangements and function arguments. Oh well, I guess that is the price you pay for something as cool as PHP that is free and open.

Hmm...

Posted: Fri Oct 21, 2005 7:42 pm
by dallasx
Wouldn't it just be easier to use the mysql functions instead of mysqli functions?

Re: Hmm...

Posted: Fri Oct 21, 2005 8:18 pm
by RobertGonzalez
dallasx wrote:Wouldn't it just be easier to use the mysql functions instead of mysqli functions?
I suppose it procedurally. But if you wanted to utilize the OOP style then you would have to either write a mysql class, download one or use mysqli. Seeing as the development world is streaming toward OOP it makes sense to get used to using an OOP style for development. This is of course just my opinion. There are still many times that I develop procedurally instead of OO.

Posted: Mon Oct 24, 2005 2:58 pm
by colorproof
Thanks for all the help guys, I really appreciate it.

Everah, when I used your code, I got this error:

Code: Select all

Parse error: parse error, unexpected '{' in /home/virtual/site222/fst/var/www/html/php/results.php on line 26
I used the original code straight from the book without any modifications (with the exception of using my own login/password and database name) so theoretically, it should work fine. The PHP version on my server should support mysqli so I don't know what is wrong. I could write it procedurally, but the book that I am working from, "PHP and MySQL Web Development" builds off this Book-O-Rama script in the continuing chapters into more complexity. I would like to continue with OOP than use procedural.

Charles, did you get a chance to test the script on your server at all?

Posted: Mon Oct 24, 2005 3:27 pm
by colorproof
Everah,

I realized that a end parenthesis was dropped from the first line:

Code: Select all

if(!$connect = mysql_connect('localhost', 'username', 'password'))
  { 
    die("Could not connect to the database server: " . mysql_error()); 
  }
after I added that, the script worked!!! YAY!!! Thanks Everah!!!

Posted: Mon Oct 24, 2005 3:58 pm
by colorproof
Ok, I figured out why the mysqli didn't work... turns out that my server DOESN'T support mysqli as I had previously thought. Thanks for everyone's help though, I am so grateful that all of you took time out of your day to help out a newbie such as myself. I hope I can return the favor sometime in the future!

Posted: Mon Oct 24, 2005 5:23 pm
by RobertGonzalez
colorproof wrote:Ok, I figured out why the mysqli didn't work... turns out that my server DOESN'T support mysqli as I had previously thought. Thanks for everyone's help though, I am so grateful that all of you took time out of your day to help out a newbie such as myself. I hope I can return the favor sometime in the future!
I sort of thought that in the beginning, but I wanted to give your host the benefit of the doubt, hence the use of procedural mysql functions. Had the mysql functions not worked then you'd have been in deep soup. With them working it would lead me to believe that PHP wasn't handling the mysqli functions for some reason.

I am glad that I was able to help. When I started developing in PHP I leaned heavily on many members of this community (Feyd is an absolute master and timvw is the PHP manual incarnate). Hope I have the opportunity to help you again someday.

Take care and happy PHP'ing.