xoombox Posted April 1, 2014 Share Posted April 1, 2014 Think there's some prase error here, but i can't figure out what is wrong. anyone? if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO kommentar (tittel, navn, tekst, tidsstempel, innleggid) VALUES ( %s, %s, %s, NOW(), %s)' GetSQLValueString($_POST['tittel'], "text"), GetSQLValueString($_POST['navn'], "text"), GetSQLValueString($_POST['tekst'], "text"), GetSQLValueString($_GET['innleggid'], "int") ); mysql_select_db($database_bloggkobling, $bloggkobling); $Result1 = mysql_query($insertSQL, $bloggkobling) or die(mysql_error()); } Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\bloggprosjekt\visinnlegg.php on line 50 Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 1, 2014 Share Posted April 1, 2014 Ugh Dreamweaver code The problem is here $insertSQL = sprintf("INSERT INTO kommentar (tittel, navn, tekst, tidsstempel, innleggid) VALUES ( %s, %s, %s, NOW(), %s)' // ^--- Should be a " double quote The single quote at the end of that line needs to be a double quote Quote Link to comment Share on other sites More sharing options...
xoombox Posted April 3, 2014 Author Share Posted April 3, 2014 (edited) I obviously failed somewhere else? idk.. I changed the ", but seems there's still something wrong. Parse error: parse error in C:\wamp\www\bloggprosjekt\visinnlegg.php on line 50 <?php require_once('Connections/bloggkobling.php'); ?> <?php mysql_select_db($database_bloggkobling, $bloggkobling); if (isset($_GET['innleggid']) > 0) { $insertSQL = sprintf("INSERT INTO visning (tidsstempel, innleggid, ip) VALUES (NOW(), %s, '%s')", mysql_real_escape_string($_GET['innleggid']), $_SERVER["REMOTE_ADDR"]); mysql_query($insertSQL, $bloggkobling) or die(mysql_error()); } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO kommentar (tittel, navn, tekst, tidsstempel, innleggid) VALUES ( %s, %s, %s, NOW(), %s)" GetSQLValueString($_POST['tittel'], "text"), GetSQLValueString($_POST['navn'], "text"), GetSQLValueString($_POST['tekst'], "text"), GetSQLValueString($_GET['innleggid'], "int") ); mysql_select_db($database_bloggkobling, $bloggkobling); $Result1 = mysql_query($insertSQL, $bloggkobling) or die(mysql_error()); } $colname_innleggvisning = "-1"; if (isset($_GET['innleggid'])) { $colname_innleggvisning = $_GET['innleggid']; } mysql_select_db($database_bloggkobling, $bloggkobling); $query_innleggvisning = sprintf("SELECT * FROM bloggvisning WHERE id = %s", GetSQLValueString($colname_innleggvisning, "int")); $innleggvisning = mysql_query($query_innleggvisning, $bloggkobling) or die(mysql_error()); $row_innleggvisning = mysql_fetch_assoc($innleggvisning); $totalRows_innleggvisning = mysql_num_rows($innleggvisning); $colname_kommentarer = "-1"; if (isset($_GET['innleggid'])) { $colname_kommentarer = $_GET['innleggid']; } mysql_select_db($database_bloggkobling, $bloggkobling); $query_kommentarer = sprintf("SELECT id, tittel, navn, tekst, DATE_FORMAT(tidsstempel,'%%d/%%m-%%Y %%H:%%i') AS tidspunkt FROM kommentar WHERE innleggid = %s ORDER BY tidsstempel DESC", GetSQLValueString($colname_kommentarer, "int")); $kommentarer = mysql_query($query_kommentarer, $bloggkobling) or die(mysql_error()); $row_kommentarer = mysql_fetch_assoc($kommentarer); $totalRows_kommentarer = mysql_num_rows($kommentarer); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if ($totalRows_innleggvisning > 0) { // Show if recordset not empty ?><table width="700" border="0" cellspacing="10" cellpadding="1"> <tr> <td width="130"><img src="bilder/<?php echo $row_innleggvisning['bilde']; ?>" alt="artikkelbilde" width="125" /></td> <td width="536"><h1><?php echo $row_innleggvisning['tittel']; ?></h1> <p><strong>Opprettet:</strong> <?php echo $row_innleggvisning['opprettet']; ?><br /> <strong>Modifisert: </strong><?php echo $row_innleggvisning['modifisert']; ?><strong><br /> Visninger:</strong> <?php echo $row_innleggvisning['antallvisninger']; ?></p></td> </tr> </table> <hr /> <p> <?php echo $row_innleggvisning['tekst']; ?></p> <hr /> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table> <tr valign="baseline"> <td nowrap="nowrap" align="right">Tittel:</td> <td><input type="text" name="tittel" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">Navn:</td> <td><input type="text" name="navn" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right" valign="top">Tekst:</td> <td><textarea name="tekst" cols="50" rows="5"></textarea></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Send" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p> <br /> <?php do { ?> <?php if ($totalRows_kommentarer > 0) { // Show if recordset not empty ?> <h3><?php echo $row_kommentarer['tittel']; ?></h3> <p><strong>Navn:</strong> <?php echo $row_kommentarer['navn']; ?><br /> <strong>Dato:</strong> <?php echo $row_kommentarer['tidspunkt']; ?><br /> <?php echo $row_kommentarer['tekst']; ?></p> <?php } // Show if recordset not empty ?> <?php } while ($row_kommentarer = mysql_fetch_assoc($kommentarer)); ?> <p> </p> <?php } // Show if recordset not empty ?> <?php if ($totalRows_innleggvisning == 0) { // Show if recordset empty ?> <p>Innlegget finnes ikke</p> <?php } // Show if recordset empty ?> </body> </html> <?php mysql_free_result($innleggvisning); mysql_free_result($kommentarer); ?> Edited April 3, 2014 by mac_gyver add code tags Quote Link to comment Share on other sites More sharing options...
jairathnem Posted April 3, 2014 Share Posted April 3, 2014 (edited) issue is with the insert command. try something like: INSERT INTO kommentar (tittel, navn, tekst, tidsstempel, innleggid) VALUES (GetSQLValueString($_POST['tittel']"text"),GetSQLValueString($_POST['navn'], "text"),GetSQLValueString($_POST['tekst'], "text"),NOW(),getSQLValueString($_GET['innleggid'], "int")) Edited April 3, 2014 by jairathnem Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 3, 2014 Share Posted April 3, 2014 @xoombox, please don't start a bunch of new threads for each and every error in your code. stick to one thread for the same type of issue, in this case syntax errors that are preventing your code from even running. your two threads have been merged together. also, please use the forum's bbcode tags (the edit form's <> button) when posting code. Quote Link to comment 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.