Whats wrong with my MySQL statement?

Posted on 2011-04-27
Last Modified: 2012-05-11
What's wrong with this?
mysql_query("DELETE * FROM universities
WHERE universityName LIKE '%Commission%'");

Open in new window

Question by:NewWebDesigner
    LVL 14

    Expert Comment

    You are missing the database connection context.

    Author Comment

    Note: If I change DELETE to SELECT and uncomment the while statement, it works.

    $con = mysql_connect("localhost","root","");
    if (!$con)
      die('Could not connect: ' . mysql_error());
    mysql_select_db("my_db", $con);
    //mysql_query("UPDATE universities SET stateID='1'"); 
     mysql_query("DELETE * FROM universities
    WHERE universityName LIKE '%Commission%'");
    //while($row = mysql_fetch_array($result))
      //echo $row['universityID'] . " " . $row['universityName'];
      //echo "<br />";

    Open in new window


    Accepted Solution

    Solved it, had to get rid of the asterisk.
    LVL 40

    Expert Comment

    try this.
    mysql_query("DELETE FROM universities
    WHERE universityName LIKE '%Commission%'");

    Open in new window


    Author Closing Comment

    I solved it myself by looking at an example.  I accidently included the asterisk.  I don't need points for solving my own problem

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now