RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Fixed that bit but still getting the same error <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php mysql_connect ("localhost","root","1234"); mysql_select_db ("company"); if (isset($_SESSION['MM_Username'])) { $row_username = $_SESSION['MM_Username']; $res=mysql_query ("select * from pictures"); echo "<table>"; while ($row=mysql_fetch_array($res)) { echo "<tr>"; echo "<td>"; ?><img src="<?php echo $row["images1"];?>" <height="100" width="100"> <?php echo "</td>"; echo "<td>"; echo $row["name"]; echo "</td>"; echo "</td>"; echo "</tr>"; } echo "</table>" ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 Fixed it, it was the { at the end of $row_username = $_SESSION['MM_Username']; but it doesn't look that its filtering my MM_Username Quote Link to comment Share on other sites More sharing options...
RidgeandGable Posted September 4, 2014 Author Share Posted September 4, 2014 ha ha it took some fiddling but I got it work. A little rough look though I must say Heres what I done, Please don't all shout at me lol still learning <?php require_once('Connections/new.php'); ?> <?php session_start() ?> <?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; } } $maxRows_Recordset1 = 10; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; $colname_Recordset1 = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_Recordset1 = $_SESSION['MM_Username']; } mysql_select_db($database_new, $new); $query_Recordset1 = sprintf("SELECT * FROM pictures WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $new) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> <!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> <table border="1"> <tr> <td>id</td> <td>username</td> <td>name</td> <td>images1</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Recordset1['id']; ?></td> <td><?php echo $row_Recordset1['username']; ?></td> <td><?php echo $row_Recordset1['name']; ?></td> <td><?php echo $row_Recordset1['images1']; ?></td> <td><img src="<?php echo $row_Recordset1["images1"];?>" <height="300" width="300"></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> </body> </html> <?php mysql_free_result($Recordset1); ?> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted September 4, 2014 Share Posted September 4, 2014 Good for you.Your script looks good for me Anyway......now, you've got a good example of separating the application logic - business from presentation. You should get into the habit of using php error handling functions while developing a project. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted September 4, 2014 Share Posted September 4, 2014 That is MUCH cleaner and very good for the PHP/HTML separation. You really shouldn't use PHP to output HTML like you originally were unless there is no other way. Doing that means PHP actually has to parse it, which takes a bit of extra processing, which takes additional time to do. Also, editors won't be able to typehint/colorize HTML if it's wrapped in PHP tags, as it's considered a PHP string at that point and not an HTML tag. I just question the < you have in the image tag right before the height="300" You will also probably want to use a HTML5 doctype and NOT XHTML. Otherwise some code will be invalid as you have written it as you don't close certain tags, like <img />. In XHTML, every HTML tag needs to be terminated. 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.