www.webdeveloper.com
Results 1 to 3 of 3

Thread: yet another php problem

  1. #1
    Join Date
    Mar 2010
    Posts
    15

    yet another php problem

    I keep finding myself always in need of some sort of assistance. In addition to the problem you guys are already helping me out, I'm getting this other error that is getting quite annoying.

    I have a form that is submitting and uploading 2 images, as well as passing along a category id. However, after submitting them to a side-upload-script, the problem reveals itself:

    I can echo the category by using

    "echo $_POST[cat]"

    just perfectly, I can also check the names of each image by using

    "$_FILES['uploaded1']['name']" and
    "$_FILES['uploaded2']['name']"

    and I have 2 variables that I want to use as directory shortcuts:

    $THUMB_ROOT = "gallery/thumbnails/";
    $IMG_ROOT = "gallery/full/";

    So far so good. Here's the problem: when I try inserting everything into my database, I get the following error:

    "Warning: Wrong parameter count for mysql_query() in C:\wamp\www\pai\jmout_12_Maio\upload.php on line 137"

    The files always get uploaded though.

    Here's my query code:
    Code:
    mysql_query("INSERT into photos 
    set
    thumbnail = '%s',
    image = '%s',
    created_at = NOW(),
    category_id = '%s'
    ",
    $THUMB_ROOT.$_FILES['uploaded1']['name'],
    $IMG_ROOT.$_FILES['uploaded2']['name'],
    $_POST[cat]
    );
    And here's my database info:

    table: photos
    5 fields:
    id (int(11)) , Not Null, auto_increment,
    thumbnail, text, not null,
    image, text, not null,
    created_at, datetime, null
    category_id (int(11)), not null

    I'd really appreciate any kind of help. Thanks again guys.

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    I think you mean to use sprintf like this:
    Code:
    mysql_query(sprintf("INSERT into photos 
    set
    thumbnail = '%s',
    image = '%s',
    created_at = NOW(),
    category_id = '%s'
    ",
    $THUMB_ROOT.$_FILES['uploaded1']['name'],
    $IMG_ROOT.$_FILES['uploaded2']['name'],
    $_POST[cat])
    );
    You can't use the mysql_query function in the way that you attempted to use it.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  3. #3
    Join Date
    Mar 2010
    Posts
    15
    Sure worked alright. Simple enough hehe. Thanks a lot

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