Jump to content

am i doing something wrong? php retreaving from mysql


lmcgr44

Recommended Posts

hello

 

i have a script that send a checkbox to the database, if it is checked it is sent to mysql as a 1 and not checked sent as 0, but when the info is sent the 1 for checked is sent to title and title is sent to ingredients and etc... these are the scripts

 

add_recipie.php

<?php
// Start_session, check if user is logged in or not, and connect to the database all in one included file
include_once("scripts/checkuserlog.php");
// Include the class files for auto making links out of full URLs and for Time Ago date formatting
include_once("wi_class_files/autoMakeLinks.php");
include_once ("wi_class_files/agoTimeFormat.php");
// Create the two objects before we can use them below in this script
$activeLinkObject = new autoActiveLink;
$myObject = new convertToAgo;
?>
<?php
// Include this script for random member display on home page
include_once "scripts/homePage_randomMembers.php"; 
?>
<?php
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing ORDER BY blab_date DESC LIMIT 30");

$blabberDisplayList = ""; // Initialize the variable here

while($row = mysql_fetch_array($sql_blabs)){

$blabid = $row["id"];
$uid = $row["mem_id"];
$the_blab = $row["the_blab"];
$notokinarray = array("fag", "gay", "shit", "fuck", "stupid", "idiot", "asshole", "cunt", "douche");
    $okinarray   = array("sorcerer", "grey", "shug", "farg", "smart", "awesome guy", "asshole", "cake", "dude");
$the_blab = str_replace($notokinarray, $okinarray, $the_blab);
$the_blab = ($activeLinkObject -> makeActiveLink($the_blab));
$blab_date = $row["blab_date"];
$convertedTime = ($myObject -> convert_datetime($blab_date));
    $whenBlab = ($myObject -> makeAgo($convertedTime));
//$blab_date = strftime("%b %d, %Y %I:%M:%S %p", strtotime($blab_date));
// Inner sql query
$sql_mem_data = mysql_query("SELECT id, username, firstname, lastname FROM myMembers WHERE id='$uid' LIMIT 1");
while($row = mysql_fetch_array($sql_mem_data)){
		$uid = $row["id"];
		$username = $row["username"];
		$firstname = $row["firstname"];
		if ($firstname != "") {$username = $firstname; } // (I added usernames late in  my system, this line is not needed for you)
		///////  Mechanism to Display Pic. See if they have uploaded a pic or not  //////////////////////////
		$ucheck_pic = "members/$uid/image01.jpg";
		$udefault_pic = "members/0/image01.jpg";
		if (file_exists($ucheck_pic)) {
		$blabber_pic = '<div style="overflow:hidden; width:40px; height:40px;"><img src="' . $ucheck_pic . '" width="40px" border="0" /></div>'; // forces picture to be 100px wide and no more
		} else {
		$blabber_pic = "<img src=\"$udefault_pic\" width=\"40px\" height=\"40px\" border=\"0\" />"; // forces default picture to be 100px wide and no more
		}

		$blabberDisplayList .= '
      			<table width="100%" align="center" cellpadding="4" bgcolor="#CCCCCC">
        <tr>
          <td width="7%" bgcolor="#FFFFFF" valign="top"><a href="profile.php?id=' . $uid . '">' . $blabber_pic . '</a>
          </td>
          <td width="93%" bgcolor="#EFEFEF" style="line-height:1.5em;" valign="top"><span class="greenColor textsize10">' . $whenBlab . ' <a href="profile.php?id=' . $uid . '">' . $username . '</a> said: </span><br />
          ' . $the_blab . '</td>
        </tr>
      </table>';
		}

}
?>
<!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=ISO-8859-1" />
    <meta name="Description" content="Web Intersect is a deft combination of powerful free open source software for social networking, mixed with insider guidance and tutorials as to how it is made at its core for maximum adaptability. The goal is to give you a free website system that has a network or community integrated into it to allow people to join and interact with your website when you have the need." />
    <meta name="Keywords" content="web intersect, how to build community, build social network, how to build website, learn free online, php and mysql, internet crossroads, directory, friend, business, update, profile, connect, all, website, blog, social network, connecting people, youtube, myspace, facebook, twitter, dynamic, portal, community, technical, expert, professional, personal, find, school, build, join, combine, marketing, optimization, spider, search, engine, seo, script" />
    <title>CookBookers</title>
    <link href="style/main.css" rel="stylesheet" type="text/css" />
    <link rel="icon" href="favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <script src="js/jquery-1.4.2.js" type="text/javascript"></script>
<style type="text/css">
#Layer1 {
height:210px;

}
.style3 {font-size: 24px}
body {
background-color: #3c60a4;
}
</style>
</head>
<body>
<p>
  <?php include_once "header_template.php"; ?>
  </head>
  <body 
style="margin:0px;">
  <center>
</p>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="mainBodyTable">
  <tr>
    <td width="235" valign="top">

    <td width="665" colspan="2" align="left" valign="top" style="background-color:#EFEFEF; border:#999 0px; padding:10px;">
<table border="0" cellpadding="6">
                <tr>
                  <td>
                     <form method="POST" action="include/recipe.php">
                              <table cellpadding="0px" border="0" align="left" cellspacing="5px" style="font-size:14px;">
                                <tr>
							  <td><span class="style3">Add New Recipie:</span><br /></td>
							  <tr>
                                  <td><h4 style="margin-bottom:5px; color:brown;">Public:</h4>
                                      <input name="Pub" value="0" type="checkbox" id="Pub" value="checkbox" />
                                </td>
                                </tr>
                                <tr>
                                  <td><h4 style="margin-bottom:5px; color:brown;">Title: </h4>
                                  <input type="text" name="title"></td>
                                </tr>
                                <tr>
                                  <td><h4 style="margin-bottom:5px; color:brown;">Makes: </h4>
                                  <input type="text" name="make"></td>
                                </tr>
                                <tr>
                                  <td><h4 style="margin-bottom:5px; color:brown;">Ingrediants: </h4>
                                  <textarea rows="10" name="ingr" cols="40"></textarea><br></td>
                                </tr>
                                <tr>
                                  <td><h4 style="margin-bottom:5px; color:brown;">Method: </h4>
                                  <textarea rows="10" name="desc" cols="40"></textarea></td>
                                </tr>
                                <tr>
                                  <td><h4 style="margin-bottom:5px; color:brown;">Notes: </h4>
                                  <textarea rows="10" name="note" cols="40"></textarea></td>
                                </tr>
                                <tr>
                                  <td><input type="submit" value="Submit" style="padding:5px 10px;"></td>
                                </tr>
                              </table>
                     </form>                  
			  </td>
    </tr>
  </table>
  </tr>
</table>
            </td>
</tr>
        </table>
	<?php include_once "footer_template.php"; ?>
</body>

 

insert recipie

<?php
//include("session.php");          
include("database.php");
@session_start();

$user = $_SESSION['username'];
    
//die($user);
$Pub=$_POST['Pub'];
    $title=$_POST['title'];
    $make=$_POST['make'];
    $ingr=$_POST['ingr'];
    $desc=$_POST['desc'];
    $note=$_POST['note'];
    //if($user=="Guest"||$user==""){
    //header("Location: ../index.php");
    //}
    //else{
    $database->AddRecipe($user,$Pub,$title,$make,$ingr,$desc,$note);
    header("Location: ../add_recipie.php");
    //}
?>

 

 

Link to comment
Share on other sites

So what's the problem?

 

the feilds are being put into mysql in the wrong ones, if i tick the public box it will place it into the title field and if i dont tick the public box it dosent put anything into the title box but everytime the title goes to the ingredents box and the ingrediants goes to the method box etc.. do u get what i mean?

Link to comment
Share on other sites

I would check the order in which your adding your information:

$database->AddRecipe($user,$Pub,$title,$make,$ingr,$desc,$note);

 

to the order of your DB columns.

 

hey thanks, my database order goes id, user, pub, title, make, ingr, desc then note, it is all in the rite order, could there be anything else wrong? like with the script?

 

i just attached a screen shot of the phpmyadmin for you to have a look

 

 

[attachment deleted by admin]

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.