Msword Posted August 3, 2007 Share Posted August 3, 2007 <?php require("dbconnect.php"); mysql_select_db("runecrypt", $sql); $personid = 1; //needs to be from variable(person.php?personid=1) note for later $name = 'Man'; $pictureurl = '/pictures/nopic.png'; $exinfo = 'look at the little noob'; $dsc = 'Theive the man when you need some cash'; $location = 'All around the world'; $quest = 'http://www.runecrypt.com/index.php?pid=49'; $membonly = 'Yes'; $contributors = 'Msword, others'; $lastupdate = 'CURDATE()'; mysql_query("INSERT INTO pdatabase (name, pictureurl, exinfo, dsc, location, quest, membonly, contributors, lastupdate) VALUES ($name, $pictureurl, $exinfo, $dsc, $location, $quest, $membonly, $contributors, $lastupdate)"); ?> isn't added anything to the table, whats wrong? Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/ Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 try to do similar to this to see the error mysql_query("INSERT INTO pdatabase (name, pictureurl, exinfo, dsc, location, quest, membonly, contributors, lastupdate) VALUES ($name, $pictureurl, $exinfo, $dsc, $location, $quest, $membonly, $contributors, $lastupdate)") or die(mysql_error()); or you would want to put a ' ' in the varibale inside that statement Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314548 Share on other sites More sharing options...
Msword Posted August 3, 2007 Author Share Posted August 3, 2007 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/pictures/nopic.png, look at the little noob, Theive the man when you need some ' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314550 Share on other sites More sharing options...
teng84 Posted August 3, 2007 Share Posted August 3, 2007 use mysql_real_escape_string Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314552 Share on other sites More sharing options...
simcoweb Posted August 3, 2007 Share Posted August 3, 2007 Put single quotes around the values. Like this: VALUES ('$name', '$pictureurl', '$exinfo', '$dsc', '$location', '$quest', '$membonly', '$contributors', '$lastupdate') Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314554 Share on other sites More sharing options...
Msword Posted August 3, 2007 Author Share Posted August 3, 2007 thanks sim, that did the trick. you rock. now the date isn't working, how to make it work? Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314561 Share on other sites More sharing options...
simcoweb Posted August 3, 2007 Share Posted August 3, 2007 No problem. Glad to help. Just an FYI, I learned 99% of what I know here in these forums. On the timestamp, do you actually need the time stamp format or just a date? As in today's date. Normally the timestamp format would be used for other calcs down the road. The CURDATE, I believe, is a MySQL function and not a PHP function. You might try replacing that with the PHP equivalent in order to get your date. If you don't need an actual timestamp then I use this format and it works great: $date = date("F j, Y, g:i a"); Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314563 Share on other sites More sharing options...
Msword Posted August 3, 2007 Author Share Posted August 3, 2007 <?php require("dbconnect.php"); mysql_select_db("runecrypt", $sql); $personid = 1; //needs to be from variable(person.php?personid=1) note for later $name = 'Man'; $pictureurl = mysql_real_escape_string('/pictures/nopic.png'); $exinfo = 'look at the little noob'; $dsc = 'Theive the man when you need some cash'; $location = 'All around the world'; $quest = mysql_real_escape_string('http://www.runecrypt.com/index.php?pid=49'); $membonly = 'Yes'; $contributors = mysql_real_escape_string('Msword, others'); $lastupdate = date("F j, Y, g:i a"); mysql_query("INSERT INTO pdatabase (name, pictureurl, exinfo, dsc, location, quest, membonly, contributors, lastupdate) VALUES ('$name', '$pictureurl', '$exinfo', '$dsc', '$location', '$quest', '$membonly', '$contributors', '$lastupdate')") or die(mysql_error()); ?> whats wrong with that? it just comes out as 0000-00-00 i only need a date, time doesn't matter, as i'm not calculating anything with this, just needs to be able to be displayed EDIT: nevermind, just used the wrong variable type on the database Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314568 Share on other sites More sharing options...
simcoweb Posted August 3, 2007 Share Posted August 3, 2007 Are you working this on your local computer or on a web host? Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314570 Share on other sites More sharing options...
Msword Posted August 3, 2007 Author Share Posted August 3, 2007 webhost. Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314575 Share on other sites More sharing options...
simcoweb Posted August 3, 2007 Share Posted August 3, 2007 Hmmm, that date code should work without a hitch. Not sure why it would return nothing unless it, for some reason, can't find the server clock. Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314577 Share on other sites More sharing options...
Msword Posted August 3, 2007 Author Share Posted August 3, 2007 i think it just wasn't it the right order for the date variable, it worked when i changed it to varchar. Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314580 Share on other sites More sharing options...
simcoweb Posted August 3, 2007 Share Posted August 3, 2007 Ahhh, ok. Quote Link to comment https://forums.phpfreaks.com/topic/63125-solved-mysql-adding-row/#findComment-314595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.