www.webdeveloper.com
Results 1 to 4 of 4

Thread: MySQL Query Function not working in MAMP - Please explain

  1. #1
    Join Date
    Sep 2013
    Posts
    1

    MySQL Query Function not working in MAMP - Please explain

    Im new to PHP/MySQL and currently reading PHP and MySQL Web Development by Luke Welling/Laura Thomson. I have been doing tutorials over the internet and I know about how individuals who post tutorials can sometimes not code the best way.

    Filename: index.php

    My problem:

    Cannot connect to database

    Example 1:
    Code:
    <?php 
    $con = mysql_connect("localhost","root","root","blog1");
    ?>
    Connects to Database

    Example 2:
    Code:
    <?php
    @ $db = new mysqli('localhost','root','root','blog1');
    
    if (mysqli_connect_errno()) {
    	echo "Error: Could not connect to database. Please try again later.";
    	exit;
    }
    Questions:

    1.Will only MySQLI work in MAMP, or is there some setting in MAMP that I need to change to use MySQL(Other functions like select and query don't work for me)?
    2.Should a beginner be learning the object orientated programming?

    Thanks in advance!

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,912
    I don't really know anything about MAMP, but I do know that the old MySQL extension has been deprecated for quite awhile now, so you'd really be doing yourself a favor by just going ahead and using the newer MySQLi extension (or even PDO). You can use it in a procedural manner very similar to the old extension, but it certainly wouldn't hurt to start getting into OOP habits as early as possible.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,035
    The irritating thing is that they constantly like to reinvent the wheel and make life harder.

    <rant>
    Take the SQLite tool, moved over to SQLite3 without giving any consideration to all those users with SQLite2 databases and no migration tool either.

    This is one of the biggest bug bearers of mine is that no consideration for backward compatibility is ever given, so what if something is depreciated, HTML4 has some right old fossil markup yet it is still supported, if a browser can support markup from the earliest websites, WTF is wrong with MySQL and SQLite people?

    SQLite3 now can't tell you how many records it has returned, it has to run the effing look up command TWICE, once to get the results, second one with the COUNT(*) function call in the query. Totally effing nutty backward retarded method if I ever saw one, its like "Oh were moving on to this platform but were taking out one of the most important functions of a query process because we think its better" total numbnutz the lot of them, give me a wall cuz that lot including MySQL and PHP lot need their heads banging against something hard to wake them up a bit.

    Some people have poured blood sweat and tears in to their code and because of a few retards in the industry, every one of the several billion users using code now has to recode their stuff.
    </rant>
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,912
    For that matter, why can't I play one of my favorite all-time PC games on Windows 7, when it worked fine on like the 4 or 5 previous versions of Windows?

    Anyway, you can still install/enable the older MySQL extension if you need to be backward-compatible with existing code, but it's difficult for me to see why you would want to create new code using it instead of the MySQLi extension, which provides both functionality and performance enhancements, and keeps it in line with the latest MySQL releases and their associated APIs.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles