insert works on SOME machines, but not on most?! Why?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

This is getting interesting! :) Thanks so much again for keeping on me with this.


You say:
INSERT INTO mytable (year, month, day) VALUES ($year, $month, $day)

assuming that year, month and day are integer fields.

If they are varchars, then you'd have to go:

INSERT INTO mytable (year, month, day) VALUES ('$year', '$month', '$day')
Would it therefore be possible to mix them together in the one INSERT line like this?

Code: Select all

INSERT INTO mytable (year, month, day, textfield1, texfield2) VALUES ($year, $month, $day, '$text1', '$text2')
(I'm going to try it anyway but I thought I'd get your opinion. I wonder if this could be my problem. My only concern is that it works on some peoples and not on others (all using the same website/server).

Did my error message help at all btw?

Thanks again :)

Rob
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

OK i did JUST that, my query is now like this:

Code: Select all

$Add = mysql_db_query ($dbname, "INSERT INTO current (id,uid,year,month,number,title,animator,hardware,software,creationtime,rendertime,viewrecommend,animdescription,descriptionofcreation,popularity,mpg,jpg,rating,ratingafter,winner)
   VALUES ($forum_uid, $forum_uid, $sound_year, $sound_month, $new_id, '$title', '$animator', '$hardware', '$software', '$creationtime', '$rendertime', '$viewrecommend', '$animdescription', '$descriptionofcreation', 0, '$mpgfilename', '$jpgfilename', 0, 0, 0)") or die(Mysql_Error());

AND..... (drumrollllllll) IT WORKS!!!!

The whole thing works on a system that previously it wouldn't work with!!! I'm so bloooody stoked!

I just want to thank everyone who helped me with this, and I hope a few others learn from it too.. You can't imagine how much this is going to help out :)


!!


Rob
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

Congrats Rob :P
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

Even more appropriately, thank you Microthick and everyone else! What a great community this is :)

Rob
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

single quotes work fine for me too.
Post Reply