Jump to content

Need Some Quick Help..


trg86

Recommended Posts

Hey guys, me again. This is all based off of the same couple of items you have helped me with the past couple of days. For those of you that know already, I have been working on a database that stores and displays information via a submitted form from the clients end. By default, all entries show up on a main page, where they can be edited, archived(which moves it to an archive page) or deleted. Now, I have the archive page working, that properly displays only archived entries, using the code below:

 

$query="SELECT * FROM leads WHERE `archive` = '1' ORDER by id DESC;

 

The problem that I am having now is that the main page, using this code:

 

$query="SELECT * FROM leads WHERE `archive` = '0' ORDER by id DESC;

 

is no longer displaying the entries once they are submitted through the form, even though it was working before, without the extra WHERE statement, which is also how it still works, but will displayed the archived leads as well, which I DO NOT want, any advice on what I may be doing wrong?

 

I added a new statement to the form processor as well to try and set the archive to 0 when it is inserted into the database, but still no luck, that code is as follows:

 

$query = "INSERT INTO leads VALUES ('','$name','$email','$age','$gender','$location','$homephone','$referrer') SET `archive` = '0' ";

 

Thanks guys!!

Link to comment
Share on other sites

Hmm I hope this was just a typing mistake. Your code at the top of the page I overlooked

 

$query="SELECT * FROM leads WHERE `archive` = '0' ORDER by id DESC;

 

You're missing the end quote

 

That was my typing mistake :) The end quote is there in the actual file.

Link to comment
Share on other sites

The following is the entire code for the main page that displays the form data, which WAS WORKING BEFORE. Additionally, I know the form is firing still because the same data is also emailed to me, as well as hitting the database.

 

<?php
session_start();
if (!isset($_SESSION['username']))
{
exit();
}
?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

$db_username="REMOVED_FOR_THIS_POST"; //Database Username
$password="REMOVED_FOR_THIS_POST"; //Database Password
$database="REMOVED_FOR_THIS_POST"; //Database Name

mysql_connect("REMOVED_FOR_THIS_POST",$db_username,$password); //Connection to Database
@mysql_select_db($database) or die("ALERT! Database not found!"); //Selection of Database

$query="SELECT * FROM leads WHERE `archive` = '0' ORDER by id DESC"; //Database Table to Query //Query Sort Settings
$result=mysql_query($query);
$num=mysql_numrows($result);

mysql_close();
?>
<html>
<head>
<link href="css/db_style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrap">
<div id="top_bar">
<font color="#0092c8"><?php echo "<b>Welcome</b> ".$_SESSION['username'];?></font>, <?php echo('<a href="logout.php">Logout</a>');?>    ||    <b>Current Database:</b> <FONT color="#0092c8" face="verdana" size="2">REMOVED_FOR_THIS_POST</font>    ||    <b>Current Date/Time:</b> <FONT color="#0092c8" face="verdana" size="2"><script type="text/javascript">
document.write ('<span id="date-time">', new Date().toLocaleString(), '<\/span>')
if (document.getElementById) onload = function () {
   setInterval ("document.getElementById ('date-time').firstChild.data = new Date().toLocaleString()", 50)
}
</script></font>
</div>
</div><br>
<div id="wrap">
<div id="top_user_toolbar">
<b>Control Panel</b> |  <a href="leads_archive.php" class="toolbar_link">Archived Leads</a>  |  <a href="#" class="toolbar_link">Active Leads</a>  |  <a href="#" class="toolbar_link">Appointment Calender</a>  |  <a href="pm/message_center.php" class="toolbar_link">Message Center</a></font>
</div>
</div><br>
<div id="wrap">
<div id="top_notification_box">
<b>Notification:</b>  <font color="#0992c8">PLEASE REPORT ANY BUGS, THIS IS A WORK IN PROGRESS!</font>
</div>
</div>
<div id="wrap">
<br><br>
<table class="leads_table">
<tr><td><center><font class="small_black"><b>New Leads</font></center></b></td></tr>
<tr>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Name</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">E-Mail</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Age</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Gender</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Location</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Phone Number</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Referrer</font></th>
<th bgcolor="#9e0219"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF"><b>- - - Options - - -</b></font></th>
</tr>
</div>
<?php
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id"); //Unique ID Field
$name=mysql_result($result,$i,"name"); //Name
$email=mysql_result($result,$i,"email"); //EMail Address
$age=mysql_result($result,$i,"age"); //Age
$gender=mysql_result($result,$i,"gender"); //Gender
$location=mysql_result($result,$i,"location"); //City of Residence
$homephone=mysql_result($result,$i,"homephone"); //Home Phone Number
$referrer=mysql_result($result,$i,"referrer"); //Referrer
?>
<tr>
<td align="center" bgcolor="#FFFFFF"><font class="lead_txt"><? echo $name; ?></font></td>
<td align="center" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $email; ?></font></td>
<td align="center" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $age; ?></font></td>
<td align="center" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $gender; ?></font></td>
<td align="center" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $location; ?></font></td>
<td align="center" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $homephone; ?></font></td>
<td align="center" bgcolor="#FFFFFF"><font face="Arial, Helvetica, sans-serif" size="2" class="lead_txt"><? echo $referrer; ?></font></td>
<td align="center" bgcolor="#fdfdfd"><a href="db_edit.php?id=<?php echo $id; ?>"><img src="images/edit.png" border="0" width="32" height="32" alt="Edit" title="Edit Lead Credentials"></a>   <a href="#"><img src="images/active.png" border="0" width="32" height="32" alt="Active" title="Move To Active Leads">   <a href="add_to_archive.php?id=<?php echo $id; ?>"><img src="images/archive.png" border="0" width="32" height="32" alt="Delete" title="Archive Lead">   <a href="db_remove.php?id=<?php echo $id; ?>"><img src="images/delete.png" border="0" width="32" height="32" alt="Delete" title="Delete Lead From Database"></a></td>
</tr>
</center>
</font>
</body>
</html>
<?php
$i++;
}
echo "</table>";
?>

Link to comment
Share on other sites

Still the same issue, as well as a possible further solution, I believe the problem may be in my processor all of a sudden. Now that I logged into my database via phpMyAdmin, the data is not even being saved to the database anymore, but is still successfully hitting my e-mail. Here is the code for my processor, maybe we can find the culprit there:

 

<?php
//
//GATHERED DATA FROM THE USERS FORM ENTRIES AND DATABASE LOGIN
//
$username="REMOVED_FOR_THIS_POST"; //Database username
$password="REMOVED_FOR_THIS_POST"; //Database password
$database="REMOVED_FOR_THIS_POST"; //Database name

$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$age = htmlspecialchars($_POST['age']);
$gender = htmlspecialchars($_POST['gender']);
$location = htmlspecialchars($_POST['location']);
$homephone = htmlspecialchars($_POST['homephone']);
$referrer = htmlspecialchars($_POST['referrer']);

mysql_connect("REMOVED_FOR_THIS_POST",$username,$password); //Connection to Database
@mysql_select_db($database) or die( "ALERT! Database not found!"); //Database Selection

$query = "INSERT INTO leads VALUES ('','$name','$email','$age','$gender','$location','$homephone','$referrer', '0')"; //Insert Form Values To Database
mysql_query($query);

mysql_close();
?>

 

Everything below that is just for sending the data to my e-mail, no relevancy. :)

Edited by trg86
Link to comment
Share on other sites

Lol, yes in answer to your question about the $i, but...

 

It was a very simple problem that I just fixed....in my database structure. There was a row below the archive row, that I removed since I am not using it at the moment, and that completely solved the problem! :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.