Help with php/MySql query
Moderator: General Moderators
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.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
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Hmm...
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.dallasx wrote:Wouldn't it just be easier to use the mysql functions instead of mysqli functions?
- colorproof
- Forum Newbie
- Posts: 9
- Joined: Fri Oct 21, 2005 12:38 pm
- Location: Oregon
Thanks for all the help guys, I really appreciate it.
Everah, when I used your code, I got this error:
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?
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 26Charles, did you get a chance to test the script on your server at all?
- colorproof
- Forum Newbie
- Posts: 9
- Joined: Fri Oct 21, 2005 12:38 pm
- Location: Oregon
Everah,
I realized that a end parenthesis was dropped from the first line:
after I added that, the script worked!!! YAY!!! Thanks 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());
}- colorproof
- Forum Newbie
- Posts: 9
- Joined: Fri Oct 21, 2005 12:38 pm
- Location: Oregon
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!
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.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 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.