|
-
Apr 20th, 2002, 12:59 PM
#1
Thread Starter
Fanatic Member
why wont this work?
sorry about all the questions, i'm VERY crappy with mysql.
PHP Code:
$mysql_select_db("fragblast",$db);
$ip=getenv('REMOTE_ADDR');
$sql = "INSERT INTO reviews (id,name,email,gamename,desc,
system,score,review,ss1,ssd1,ss2,
ssd2,ss3,ssd3,ip,password) VALUES ('','$name',
'$email','$gid',
'$desc','$system',
'$score','$review','$ss1','$ssd1','$ss2','$ssd2',
'$ss3','$ssd3','$ip','$password')";
$result = mysql_query($sql);
print 'Thank you, your review has been submitted into the database';
whenever i add something, nothing gets inserted into the table
it doesnt give any errors. the first field, "id", is auto-increment
Last edited by nabeels786; Apr 20th, 2002 at 05:38 PM.
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 01:40 PM
#2
PowerPoster
leave ID out alltogether, don't even set it to a zero length string
-
Apr 20th, 2002, 01:42 PM
#3
Thread Starter
Fanatic Member
still doesn't work
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 03:50 PM
#4
PowerPoster
hmm...
are all the table and field names correct?
have you permission to insert into tables?
unlikely, but try seperating comma values with a space...sometimes it gets upset about that
e.g. name, email, gamename, desc etc
-
Apr 20th, 2002, 04:40 PM
#5
Thread Starter
Fanatic Member
how do you give permission to insert into a table?
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 05:12 PM
#6
PowerPoster
if it's your computer, save yourself a lot of bother and download phpmyadmin from here http://phpwizard.net/projects/phpMyAdmin/
Install on your computer then use it to open the mysql table. From there you can change permissions for all the users
If it's a remote server run by somebody else, you can try doing that but I wouldn't fancy your chances. Ask them if you have permission and if not, to grant it to you.
-
Apr 20th, 2002, 05:15 PM
#7
Thread Starter
Fanatic Member
yeah thats what im using. but how exactly do i add in permissions?
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 05:18 PM
#8
PowerPoster
On the main page, you'll see a Users link. Click that and you'll get the permissions page, where you can specify down to a fine level all the things a user can do
-
Apr 20th, 2002, 05:22 PM
#9
Thread Starter
Fanatic Member
Yep, I have permissions for everything, still won't add anything in
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 05:25 PM
#10
PowerPoster
okay
Is all the data valid?
e.g. are you trying to insert text into a number field anywhere?
-
Apr 20th, 2002, 05:30 PM
#11
Thread Starter
Fanatic Member
everything is a text field except id
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 05:32 PM
#12
PowerPoster
try getting phpmyadmin to do the query. If that can't do it either, there must be something wrong with mysql.
-
Apr 20th, 2002, 05:39 PM
#13
Thread Starter
Fanatic Member
the query
"INSERT INTO reviews (name) VALUES ('testing')"
works fine, within SQL admin. im making a quick page to check whether it works on a page
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 05:44 PM
#14
Thread Starter
Fanatic Member
my mini test page worked fine, i guess there is something wrong with my query
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 06:41 PM
#15
try this
PHP Code:
$mysql_select_db("fragblast",$db);
$ip=getenv('REMOTE_ADDR');
$sql = "INSERT INTO reviews (id,name,email,gamename,desc,
system,score,review,ss1,ssd1,ss2,
ssd2,ss3,ssd3,ip,password) VALUES ('','$name',
'$email','$gid',
'$desc','$system',
'$score','$review','$ss1','$ssd1','$ss2','$ssd2',
'$ss3','$ssd3','$ip','$password')";
$result = mysql_query($sql);
echo $sql;
if (!$result){
echo mysql_error($result)
}
print 'Thank you, your review has been submitted into the database';
I think I have that right. it will print out the insert statment to see if you have the query right. you can comment it out after it is working properly. also the mysql_error will tell you if there is a problem with you query. I think I have the correct syntax for mysql_error, if not I will post it later. I am not at my computer right now so don't have nothing to confirm it.
-
Apr 20th, 2002, 07:03 PM
#16
Thread Starter
Fanatic Member
Here whats i got
INSERT INTO reviews (id,name,email,gamename,desc, system,score,review,ss1,ssd1,ss2, ssd2,ss3,ssd3,ip, password) VALUES ('','Nabeel',' [email protected]','','sdf','pcgame','7','sdf','','','','','','','127.0.0.1','just atest')
Warning: Supplied argument is not a valid MySQL-Link resource in c:\inetpub\wwwroot\reviews\submit.php on line 167
its the ss1..stuff, those are optional fields, i guess its complaining hat they're blank. how do i specify that those can be blank?
edit: its not complaining about that, i entered everything in...bah?
Last edited by nabeels786; Apr 20th, 2002 at 07:10 PM.
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 07:19 PM
#17
PowerPoster
I don't know what to say dude, it's beyond me why there is anything wrong with that query but
Warning: Supplied argument is not a valid MySQL-Link resource in c:\inetpub\wwwroot\reviews\submit.php on line 167
means there is something wrong with it because it couldn't return a valid pointer
Perhaps you have set a restriction on the fields not to accept null values?
-
Apr 20th, 2002, 07:24 PM
#18
Thread Starter
Fanatic Member
the attributes are "not null" for all of them, if thats what you mean
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 07:27 PM
#19
PowerPoster
yes, that is what I meant.
Did you try using phpmyadmin to run the query outputted by the code scoutt gave you?
-
Apr 20th, 2002, 07:29 PM
#20
Thread Starter
Fanatic Member
lets see
MySQL said:
You have an error in your SQL syntax near 'desc, system,score,review,ss1,ssd1,ss2, ssd2,ss3,ssd3,ip, password) VALUES ('','' at line 1
maybe its the spaces thing?
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 07:34 PM
#21
PowerPoster
can't hurt to try. I always space them so I wouldn't know if not spacing works or not
-
Apr 20th, 2002, 07:41 PM
#22
Thread Starter
Fanatic Member
i spaced them out, then took out the spaces, still didnt do anything. I cant find anything wrong with the peice of code it said was errored
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 20th, 2002, 11:29 PM
#23
Originally posted by chrisjk
I don't know what to say dude, it's beyond me why there is anything wrong with that query butmeans there is something wrong with it because it couldn't return a valid pointer
Perhaps you have set a restriction on the fields not to accept null values?
the reason you got that error is because one of the category names maybe wrong.
double check your category names. I think it is picky as to the spaces, not sure. keep it all one line. I did notice a space after desc, and nothing on anything else.
$sql = "INSERT INTO reviews (id,name,email,gamename,desc,system,score,review,ss1,ssd1,ss2,ssd2,ss3,ssd3,ip,password) VALUES ('','$name','$email','$gid','$desc','$system','$score','$review','$ss1','$ssd1','$ss2','$ssd2','$ss3 ','$ssd3','$ip','$password')";
-
Apr 21st, 2002, 09:59 AM
#24
Thread Starter
Fanatic Member
i fixed it, iguess it didnt like the name "desc", i changed it to "describ", and it worked fine
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Apr 21st, 2002, 10:43 AM
#25
PowerPoster
OMG I can't beleive I didn't notice!!
DESC is a keyword in the ORDER BY clause, so it got confused
-
Apr 21st, 2002, 10:49 AM
#26
Thread Starter
Fanatic Member
lol, yep that could be a problem,
thanks for the help though
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|