# Why wont this work? PHP and MySQL HELP!

**URL:** <https://www.phphelp.com/t/why-wont-this-work-php-and-mysql-help/12861>\
**Category:** General PHP Help\
**Created:** [March 12, 2011, 3:39am UTC](https://www.phphelp.com/t/why-wont-this-work-php-and-mysql-help/12861 "2011-03-12T03:39:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex1646](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@Alex1646](https://www.phphelp.com/u/Alex1646)\
**Post date:** [March 12, 2011, 3:39am UTC](https://www.phphelp.com/t/why-wont-this-work-php-and-mysql-help/12861/1 "2011-03-12T03:39:14Z")

</div>

I am creating a website where writers can share stories, in the upload script there is a option to save a file as a draft. If the user checks this option, a Y is put in a row in my mysql database called draft.  
Here is the structer of my mysql db  
[hr]  
title sum notes story user story\_id cat rating series\_id chap\_numb draft  
[hr]  
In the page where the drafts for that user is displayed (called draft) I want to list all of that users drafts, but it doesn’t seem to be working. I check the sourse and any field that I use a variable for is left blank. Here is the code on the page:  
[php]

\<?php if (isset($user\_log)) { //\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* $user = $\_SESSION['user']; $query = " SELECT \* FROM story\_info WHERE user = '$user' AND draft = 'Y' "; $select = mysql\_query($query) or die(mysql\_error()); echo mysql\_num\_rows($select); if (mysql\_num\_rows($select)!=0) { while($rows = mysql\_fetch\_assoc($select) or die(m) ); { $titledb = $rows['title']; $sumdb = $rows['sum']; $id\_db = $rows['story\_id']; $notesdb = $rows['notes']; $storydb = $rows['story']; $catdb = $rows['cat']; $ratdb = $rows['rating']; $userdb = $rows['user']; $seriesid\_db = $rows['series\_id']; $chapnumb = $rows['chap\_numb']; echo "
* * *

### $titledb
$sumdb
* * *
"; } } else { echo "
 No Drafts! 
"; } //\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* } else { echo "
 Please sign in to view this page! 
 "; } ?\>

[/php]  
Here is the code on the template page:

```auto
<?php session_start(); ?>
<!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>
<script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
<script type="text/javascript">bkLib.onDomLoaded(nicEditors.allTextAreas);</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type='text/javascript'>
function checkForm() 
{
if (document.getElementById(yob) == undefined)
{
	alert('Enter Year Of Birth!');
	
}

}
</script>
<style type="text/css">
#message 
{
	font:Arial, Helvetica, sans-serif	;
	text-align:center;
	font-size:2em;
	
}
#error
{
	border-width:2px;
	border-style:dashed;	
	border-color:#F00;
	background-color:#F96254;
	margin:auto;
	width:500px;

}
label 
{
	display:block;
}

#impor
{
	color:#F00;
	font-weight:bold;
}
.story 
{
	background-color: #E6EFF9;
	width: 801px;
	float:right;
	padding:10px;
	margin-right:375px;
	margin-bottom:10px;
}
.story_info
{
	background-color:#A3ACB5;
	width:217px;
	min-height: 755px;
	
}

	.info 
{
 	width: 1900px;
	background-color:#44719D;
	height:50px;
}
	
	
	

</style>
<?php

if (isset($_COOKIE['user']))
{
	$user_log = $_COOKIE['user'];
}
else
{
	$user_log = $_SESSION['user'];	
}
 ?>
<?php include('logic.inc'); mysqlConnect(); ?>
<script type="text/javascript" src="bbeditor/ed.js"></script>
<link rel="stylesheet" type="text/css" href="bbeditor/styles.css" />
<title>
<?php
echo 'social';
?>
</title>
<script type="text/javascript">
function changeTitle(title) 
{
	 document.title = title; 
}
</script>

</head>

<body>
<div class="content">
  
    <?php
	//enbed a page
@$page = $_GET['p'];
$path = "inc/$page.php";
//check if file exsists

if (file_exists($path))
{
	include($path);
}
//if not desplay message
else 
{
	die("<div id='message'> Page doesn't exsist. </div>");
}

/*
$rand = rand('1','2');
$include = "spon/spon$rand.php";
include($include);
*/

?>
</div>

</body>
</html>
```

What do you think is wrong ☹

---

<div class="post-metadata">

**Author:** ![Alex1646](https://www.phphelp.com/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@Alex1646](https://www.phphelp.com/u/Alex1646)\
**Post date:** [March 12, 2011, 3:48am UTC](https://www.phphelp.com/t/why-wont-this-work-php-and-mysql-help/12861/2 "2011-03-12T03:48:49Z")

</div>

:(. I posted in the wrong area. I reposted in the General Php Section. I am not sure how to delete this.
