Jump to content

PHP/mySql - Data doesn't save into database :(


Chezshire

Recommended Posts

Hello, I'm very new and still consider myself to be complete newb when little more then two months of playing around with php, mySql and javaScript. I'm trying to add a simple pulldown menu which will allow posters to add ratings to their postings based on the content. Everything on the front end seems to work, but the value for the post rating is not transmitted/stored in my mySql database. I think i'm doing something wrong with the mySql calls maybe but i'm not sure. Any help is appreciated!

 

Please note that I inherited the site i'm working on - it was built by someone much more knowledgible then I and I am just a complete newb who is still learning about all of this stuff. As always any help is appreciated.

 

This is the PHP code which is set up how i usually do my pull downs - it's working properly.

<tr>
<td style="text-align: right"><p>RATING:</p></td>
<td><select name="rating">
	<option value="4">1</option>
	<option value="2">2</option>
	<option value="3"<?php if ($record["rating"]=="3") { echo " selected"; } ?>>3</option>
	</select>
</td>
</tr>

This is the Submit code at the bottom of the page to submit the info to the mySql database (board)

<tr>
<td align="right"><p><span id="threadCheck" class="fineprint">Click to post.</span></td>
<td><p><input type=submit name=submit value="<?php echo $buttonText; ?>" style="background-color:#022755;color:#FFFFFF;"></form></td>
</tr>
</table>

<?php

if (($id && !$charid) || checkOOC($thread)) {
echo "<!-- WE'RE FORCING OOC FOR SOME REASON. -->\n";
echo "<!-- ID: $id      THREAD: $thread -->\n";
echo "<SCRIPT LANGUAGE=\"javascript\">\n";
if ((!$charid && !$storyteller) || checkOOC($thread)) { echo "makeOOC('force');\n"; } else { echo "postWarning();\n"; }
echo "</SCRIPT>\n\n";
} // end if thread

include("../countdownUniversal.php");
include("../footer.php"); ?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/122936-phpmysql-data-doesnt-save-into-database/
Share on other sites

Hello and thanks

  I believe that you've hit the nail on the head - in that I'm not completely sure where the insert query on this page is. I though that this was the insert query and that i'd done everything correctly to activate it but clearly i haven't as it does not work.

if (!$id) {
$sql = "INSERT INTO board (userid,
charid,
storyteller,
subject,
previously,
rating,
content,
summary,
dateadded, lastmodified,
ooc,
featuring,
tags,
timeofday,
location,
thread,
gamedate,
continuedfrom,
notification,
approved) VALUES (\"$login\",
\"$CHARID\",
\"$STORYTELLER\",
\"$SUBJECT\",
\"$PREVIOUSLY\",
\"$RATING\",
\"$CONTENT\",
\"$SUMMARY\",
NOW(),
NOW(),
\"$OOC\",
\"$FEATURING\",
\"$TAGS\",
\"$TIMEOFDAY\",
\"$LOCATION\",
\"$THREAD\",
\"$GAMEDATE\",
\"$CONTINUEDFROM\",
\"$NOTIFICATION\",
\"$ACTION\")";
} else {
if (!$THREAD) { $THREAD = $id; }
$sql = "UPDATE board SET charid=\"$CHARID\", 
storyteller=\"$STORYTELLER\",
thread=\"$THREAD\", 
subject=\"$SUBJECT\",
previously=\"$PREVIOUSLY\",
rating=\"$RATING\",
summary=\"$SUMMARY\", 
content=\"$CONTENT\",
ooc=\"$OOC\",
featuring=\"$FEATURING\",
tags=\"$TAGS\",
timeofday=\"$TIMEOFDAY\", 
location=\"$LOCATION\",
gamedate=\"$GAMEDATE\",
continuedfrom=\"$CONTINUEDFROM\", 
notification=\"$NOTIFICATION\", 
approved=\"$ACTION\",
dateadded=$modDate WHERE id=$id";
} // end if ID

 

Thanks for any help or guidance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.