Jump to content

vinpkl

Members
  • Posts

    448
  • Joined

  • Last visited

Posts posted by vinpkl

  1. use single quotes for values

    
    values('$id','$row[image]','$row[product_name]',1,'$row[price]'
    

     

    hi zenag

     

    when i used this code

     

    <?php
    $qry="insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values('$id','$row[image]','$row[product_name]',1,'$row[price]','$row[shipping_cost]','$row[price]'+'$row[shipping_cost]')";
    ?>
    

     

    then i received this error

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\xampp\htdocs\vineet\shopping_cart.php on line 12
    insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values('','','',1,'','',''+'')
    

  2. try ...

     

    row13

    values(".$id.",".$row['image']."," .......
    

     

    hi

     

    when i used this code

     

    <?php
    $qry="insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values(".$id.",".$row['image'].",".$row['product_name'].",".1.",".$row['price'].",".$row['shipping_cost'].",".$row['price']."+".$row['shipping_cost'].")";
    ?>
    

    then i received

     

    Parse error: syntax error, unexpected T_DNUMBER in E:\xampp\htdocs\vineet\shopping_cart.php on line 13.

     

    also in concatination of ".1." one dot is red and one is blue

     

    vineet

     

     

  3. hi all

     

    i m inserting data from my product table into cart table and getting this error

     

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in E:\xampp\htdocs\vineet\shopping_cart.php on line 13
    

     

    This is my complete code

    <?php
    require_once("config.php");
    $_SESSION['product_id']=$_REQUEST['product_id'];
    $_SESSION['product_id']=$_REQUEST['product_id'];
    $id=$_SESSION['product_id'];
    //echo test;
    //exit;
    $qry="select product_id,image,product_name,price,shipping_cost from product_table where product_id=". $_SESSION['product_id'];
    //echo $qry;
    //exit;
    $result=mysql_query($qry);
        $row=mysql_fetch_array($result);
    $qry="insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values($id,$row['image'],$row['product_name'],1,$row['price'],$row['shipping_cost'],$row['price']+$row['shipping_cost'])";
    
    echo $qry;
    exit;
    mysql_query($qry);
    
    ?>
    
    

     

    This is line no.13

    $qry="insert into cart_table(product_id,image,product_name,quantity,price,shipping_cost,total_cost) values($id,$row['image'],$row['product_name'],1,$row['price'],$row['shipping_cost'],$row['price']+$row['shipping_cost'])";
    

     

    what is causing error in my code.

     

    vineet

  4. hi all

     

    I have to scripts. One script displays the image and other script displays swf file. But both the image and swf are to displayed at the same location. so i want to toggle them.

    If the user uploads an image then image should displayed as image, else if the user uploads an swf file then the swf file should be displayed.

     

    here is my script that displays image

    $qry="select * from special_offers where location='right side'";	
    $result = mysql_query($qry);			  
    if(mysql_num_rows($result)>0)
    {
    	while($row=mysql_fetch_array($result))
    	{
    
    	echo "<td>". "<img height=200 width=250 src='uploads/" . $row['offer_image'] . "'/>" . "</td>";
    
    	}
    }
    

     

    Here is my script that displays swf file

    $qry="select * from special_offers where location='right side'";	
    $result = mysql_query($qry);			  
    if(mysql_num_rows($result)>0)
    {
    	while($row=mysql_fetch_array($result))
    	{
    
    	echo "<td>"; 
    	echo "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='250' height='200'>";
      echo "<param name='movie' value='admin/uploads/" . $row['offer_image'] ."'/>";
      echo "<param name='quality' value='high' />";
      echo "<embed quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer'   type='application/x-shockwave-flash' width='250' height='200'  src='admin/uploads/" . $row['offer_image']."'>" . "</embed>";
    echo "</object>";
    	echo "</td>";
    
    	}
    }
    
    
    

     

    how can i toggle them. i dont want to detect flash player. just display the image or swf according to the user input.

     

    vineet

  5. why not just check for the id??  surly the admin id would be 1 so

     

    <?php
    if($row['id'] == "1") {
    // display page
    } else {
    // redirect to main page
    header("Location: mainpage.php");
    }
    ?>

     

    Hi

     

    i tried with ID also. It restricts the page to be accessed without login but

    the problem i m facing is that even if i have entered user and password corectly it doesnot

    redirect me to control_panel.php

     

    If i remove this script from control_panel.php then after entering user name and password

    it redirects to control_panel.php

     

    in control_panel.php i m writing

    if($row['id'] == "2") 
    
    {
    header("Location:control_panel.php");
    } 
    else {
    // redirect to main page
    header("Location:index.php");
    }
    
    

     

    vineet

  6. By

     

    // Display page

     

    He means to put the code in there that displays the page you want to view, if they are authenticated.

     

    hi

     

    thanks for the reply. it worked well. I just wanted to know what should i write in my "logout" page.

     

    i have started

    session_start();

     

    in my config.php which is included file in every admin page.

     

    vineet

  7. By

     

    // Display page

     

    He means to put the code in there that displays the page you want to view, if they are authenticated.

     

    hi

     

    ok that is fine.

     

    One thing i want to know that i will put this code in all the admin pages except the login page.

     

    and what will be the datatype for the authority column in database

     

    vineet

  8. have a column in the user table that is called something like "authority", and then run a check on the Admin only pages.

    <?php
    if($row['authority'] == "admin") {
    // display page
    } else {
    // redirect to main page
    header("Location: mainpage.php");
    }
    ?>

     

    hi

     

    what will be the datatype to be selected for "authority" column.

     

    and where you have written in code

     

    // display page

     

    do i have to write the page name or leave it as comment

     

    vineet

     

     

    vineet

  9. hi

     

    i am working on admin section which has a login page with login id and pasword form.

     

    In my admin section i have many pages say like manage_products.php, description.php, control_panel.php etc.

     

    if the user have to access the manage_products.php page then he can access it just typing like the link below

     

    http://localhost/vineet/admin/manage_products.php

     

    without entering login user and pasword.

     

    i want to restrict the access of this page through admin panel only. The user should be able to access page only if he is logged in.

     

    vineet

  10. I assume shipping details is:

     

    123 Street

    2nd Address

    SomeWhere, ST 12345

     

    I don't have a lot of stars by my name but this is how I handle address info.

     

    It makes validation easier also.

     

    <?
    
    if(isset($_POST['submit']))
    {	
    $Street1=$_REQUEST['Street1'];
    $Street2=$_REQUEST['Street2'];
    $City=$_REQUEST['City'];
    $State=$_REQUEST['State'];
    $Zip=$_REQUEST['Zip'];
    
    
    /** put your insert code here **/
    
    echo $Street1; 
    echo $Street2;  
    echo $City;
    echo $Zip;  
    
    /** end your insert code here **/
    
    
    }
    
    ?>
    
    <form action='' method=post>
    <input name='Street1' size=40 /><br />
    <input name='Street2' size=40 /><br />
    <input name='City' size=20 /><input name='State'  size=2/><input name='Zip' size=9 />
    <br /><br />
    <input type=submit name=submit value=submit>
    </form>

     

    hi

     

    well its not address its detail about shipping, how many days wil it take, from where product will be shipped, about courier and all that.

    it can be 3 lines, may be 5 or 6. thats why i have inserted <textarea>.

     

    Here is the result

    --------------------

    3-7 days shipping. Product shipped from delhi.

    ----------------------

    I want to insert <br> before Product word starts.

     

    if i didnt get any solution for <textarea> then i have to adopt your solution.

     

     

    vineet

  11. Can you post your code that is sent after submit?

     

    hi

     

    here is the code

     

    
    if(isset($_REQUEST['submit']))
    {	
    $shipping_detail=$_REQUEST['shipping_detail'];
    $warranty=$_REQUEST['warranty'];
    
    $insertqry="insert into product_table(shipping_detail,warranty) values('$shipping_detail','$warranty')";
    
    if(mysql_query($insertqry))
    $msg="shipping Product added successfully";
    else
    $msg="Error Inserting new product";
    }
    
    

     

    Here is the result

    --------------------

    3-7 days shipping. Product shipped from delhi.

    ----------------------

     

    I want to insert <br> before Product word starts

  12. hi all

     

    i would like to ask that i have a <textarea> and in that i can insert 3 lines.

    If the content is entered with "pressing enter" after each line then i want that 3 lines ouput should come with a break after each line. means i just want to add <br> after each line ouput.

    the name of <textarea> is shipping_detail.

     

    $shipping_detail=$_REQUEST['shipping_detail'];
    

     

    vineet

  13. This:

    echo "<td valign=top>". $row['detail_description'] . "</td>";

     

    Needs to be

    echo "<td valign=top>". $desc . "</td>";

     

    Hi

     

    thanks a lot. Its now working perfect.

    one thing more i would like to ask that i have a <textarea> and in that i can insert 3 lines. i just want to how can those 3 lines should come with a break after each line. means i just want to add <br> after each line.

    the name of <textarea> is shipping_detail.

     

    <?php echo $row['shipping_detail']; ?>
    

     

    vineet

  14. Something like the following should do

    $sql = 'SELECT * FROM your_table';
    $result = mysql_query($sql) or die('MySQL Error: ' . mysql_error());
    
    while($row = mysql_fetch_assoc($result))
    {
        $desc = short_description($row['description']);
        echo $desc;
    }
    
    function short_description($text, $max_lines = 4)
    {
        // standardize new lines
        $text = str_replace(array("\r\n", "\r"), "\n", $text);
    
        // get each line
        $lines = explode("\n", $text);
    
        // retieive the requires lines
        $list = array();
        for($i = 0; $i <= $max_lines; $i++)
        {
            $list[] = $lines[$i];
        }
    
        // add closing ul tag
        $list[] = '</ul>';
    
        return implode("\n", $list);
    }

     

     

    hi

    i have used this in my code but its showing the full 20 lines.

     

    
    if(isset($_REQUEST['submit']))
    {			
    $model=$_REQUEST['model'];
    
    $qry="select * from product_table where product_name LIKE '%$model%' ";   
    
    $result = mysql_query($qry);           
       if(mysql_num_rows($result)>0)
       {
       while($row=mysql_fetch_array($result))
       {
      $desc = short_description($row['detail_description']);   
          echo "<table>";
          echo "<tr>";
          echo "<td width=148 class=products>Image</td><td width=148 class=products>Product Name</td><td class=products width=148>Description</td><td width=148 class=products>Cutout Price</td><td width=148 class=products>Price</td>";
          echo "</tr>";
          echo "<tr>";
          echo "<td width=125>" . "<img width=116 height=117 src='admin/uploads/" . $row['image'] . "'/>" . "</td>";
          echo "<td valign=top  width=125>". $row['product_name'] . "</td>";
          echo "<td valign=top>". $row['detail_description'] . "</td>";
          echo "<td valign=top class=cut>". "NZ$ " . $row['cutout_price'] . "</td>";
          echo "<td valign=top>".  "NZ$ " . $row['price'] . "</td>";
          echo "</tr>";
      	  echo "<tr>";
     echo "<td valign=top colspan=5 align=right>". "<a href=description.php?id=" . $row['product_id'] . ">" ."<img src='images/details.gif' border=0 />" . "</a>" . "</td>";
      echo "</tr>";
      echo "<tr>";
      echo "<td class=products_sep colspan=5>" . "<image src='images/spacer.gif' height=15 width=15>" . "</td>";
      echo "</tr>";
    
          echo "</table>";
       }
        
       }
       else
       echo "No Results found !";
    }			
    
    function short_description($text, $max_lines = 4)
    {
        // standardize new lines
        $text = str_replace(array("\r\n", "\r"), "\n", $text);
    
        // get each line
        $lines = explode("\n", $text);
    
        // retieive the requires lines
        $list = array();
        for($i = 0; $i <= $max_lines; $i++)
        {
            $list[] = $lines[$i];
        }
    
        // add closing ul tag
        $list[] = '</ul>';
    
        return implode("\n", $list);
    }	
    

  15. In what format is the data in your description field, eg

     

    Format 1

    Line 1<br />Line 2<br />Line 3

     

    Or, Format 2

    Line 1<br />
    Line 2<br />
    Line 3

     

    Or

    Line 1
    Line 2
    Line 3

     

    We'll need to know this in order for us to provide a suitable answer.

     

    hi

     

    my data is in Format 2.

    It contains the <ul></li> tags and the data with <li> tags. like bulleted content.

    <li>line 1</li>
    <li>line 2</li>
    

  16. hi all

     

    i have index page and description page.

    In description page i am able to show the complete list of the features of my products which are fetched from database in 20 lines. Means each product has a long description of 20 lines each.

    Now i want to show only 4 lines out of those 20 lines in my index page for my each product.

     

    how can i fetch only 4 lines out of those 20 lines.

     

    the name of my description field in my form is "description".

     

     

    vineet

  17. try

    $qry="select * from admin_table WHERE `user_name`='$user_name' and `password`='$password' LIMIT 1";

     

    hi this is the new code i have replaced $qry up also and down also

     

    require_once("../config.php");
    
    $msg="";
    if(isset($_POST['id']))
    {
    $id=$_POST['id'];
    //$qry="select * from admin_table where user_id=$id";
    //$qry="select * from admin_table where user_id=$id LIMIT 1";
    $qry="select * from admin_table WHERE `user_name`='$user_name' and `password`='$password' LIMIT 1"; 
    $result=mysql_query($qry);
    $row=mysql_fetch_array($result);
    }
    
    if(isset($_POST['submit']))
    {
    $user_name=$_POST['user_name'];
    $password=$_POST['password'];
    
    $qry="select * from admin_table WHERE `user_name`='$user_name' and `password`='$password' LIMIT 1"; 
    $result=mysql_query($qry);
    echo $qry;
    
    if(mysql_num_rows($result)>0)
    {
    
    	if(($user_name==$row['user_name']) && ($password==$row['password']))
    
    	{
    	header("Location: control_panel.php");
    
    	/*echo "<SCRIPT language='javascript'>";
            echo "window.location='control_panel.php'";
    	echo "</script>";*/
    	}
    	else
    	{
    	$msg="Login ID or password is incorrect";
    	}
    }
    }
    

     

    In the echo result i got the corect user password as in database.

    select * from admin_table WHERE `user_name`='vineet' and `password`='23456' LIMIT 1 
    

    I didnt get mysql_numrow error that i got earlier. but it says incorect user password and didnt redirect.

     

    where i have the code

    $id=$_POST['id'];

    there also i have change it to new qry that you have sent now.

  18. change all $_REQUEST to $_POST

     

    change this...

    $qry="select * from admin_table where user_id=$id";

    to this...

    $qry="select * from admin_table where user_id=$id LIMIT 1";

     

    change...

       $qry="select * from admin_table";

    to...

       $qry="select * from admin_table WHERE `user_name`='$user_name',`password`='$password' LIMIT 1";

     

    Hi

     

    This is the new code

     

    require_once("../config.php");
    
    $msg="";
    if(isset($_POST['id']))
    {
    $id=$_POST['id'];
    //$qry="select * from admin_table where user_id=$id";
    $qry="select * from admin_table where user_id=$id LIMIT 1";
    $result=mysql_query($qry);
    $row=mysql_fetch_array($result);
    }
    
    if(isset($_POST['submit']))
    {
    $user_name=$_POST['user_name'];
    $password=$_POST['password'];
    
    //$qry="select user_name,password from admin_table where user_name='$user_name'";
    $qry="select * from admin_table WHERE `user_name`='$user_name',`password`='$password' LIMIT 1";
    $result=mysql_query($qry);
    echo $qry;
    
    if(mysql_num_rows($result)>0)
    {
    
    	if(($user_name==$row['user_name']) && ($password==$row['password']))
    
    	{
    	header("Location: control_panel.php");
    
    	/*echo "<SCRIPT language='javascript'>";
            echo "window.location='control_panel.php'";
    	/*echo "</script>";*/
    	}
    	else
    	{
    	$msg="Login ID or password is incorrect";
    	}
    }
    }
    

     

    I have inserted echo $qry; in the code and on submitting the result i get is

    select * from admin_table WHERE `user_name`='vineet',`password`='23456' LIMIT 1
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in E:\xampp\htdocs\vineet\admin\index.php on line 24
    

     

    The user and id that the code has fetched is the same as in database.

  19. is the password in the database md5 hashed? if so, change this line....

    if(($user_name==$row['user_name']) && ($password==$row['password']))

     

    to...

    if(($user_name==$row['user_name']) && (md5($password)==$row['password']))

     

    hi

     

    i dont know anything about md5 and i have not used it anywhere

     

    vineet

  20. change this...

    <?php
          //header("location:control_panel.php");
          echo "<SCRIPT language=javascript>";
            echo "window.location='control_panel.php'";
          echo "</script>";

     

    to this...

    <?php
         header("Location: control_panel.php");

     

    i used this but its giving error that the login or password is incorect. i have checked and matched in the database. i m filing the corect login and pasword but stil its saying its incorect.

     

    vineet

  21. hi all i have a login form with user name and password. The user name field is called "user_name" and password field is called "password".

    I have applied the code. If the user and password is incorect then its showing error that the user and pasword doesnot match. that is working fine. But if the user and password is corect then it doesnt redirect to file control_panel.php and neither show any error.

    In the database i have user_id, user_name, password.

     

    <?php
    require_once("../config.php");
    
    $msg="";
    if(isset($_REQUEST['id']))
    {
    $id=$_REQUEST['id'];
    $_SESSION['id']=$id;
    $qry="select * from admin_table where user_id=$id";
    $result=mysql_query($qry);
    $row=mysql_fetch_array($result);
    }
    
    if(isset($_REQUEST['submit']))
    {
    $user_name=$_REQUEST['user_name'];
    $password=$_REQUEST['password'];
    
    $qry="select * from admin_table";
    $result=mysql_query($qry);
    
    if(mysql_num_rows($result)>0)
    {
    
    	if(($user_name==$row['user_name']) && ($password==$row['password']))
    	{
    	//header("location:control_panel.php");
    	echo "<SCRIPT language=javascript>";
            echo "window.location='control_panel.php'";
    	echo "</script>";
    	}
    	else
    	{
    	$msg="Login ID or password is incorrect";
    	}
    }
    }
    ?>
    

  22. hi

     

    thanks thanks a lot. works perfect as needed.

     

    vineet

     

     

    OK that makes more sense  :)

     

    try the below

     

    
    if(isset($_REQUEST['status']))
    {
    $pid=$_REQUEST['status'];
    echo $pid;
    $qry="select * from product_table where product_id=$pid";
    $result=mysql_query($qry);
    $row=mysql_fetch_array($result);
    if($row['status']=='Y')
    {
    $updtqry="update product_table set status='N' where product_id=$pid";
    mysql_query($updtqry,$conn) or die("Not updated");
    }
    else
    {
    $updtqry="update product_table set status='Y' where product_id=$pid";
    mysql_query($updtqry,$conn) or die("Not updated");
    }
    }	
    
    

     

    <table width="901" cellpadding="6" cellspacing="0" class="bordr">
          <tr style="background-color:#CCCCCC; height:25px">
            <td>Product ID </td>
            <td>Product Name </td>
            <td>Description </td>
    	<td>Cutout Price</td>
    	<td>Price</td>
    	<td>Product Image</td>
    	<td>Shipping cost</td>
    	<td>Shipping detail</td>
    	<td>warranty</td>
                              <td>Show/hide</td>
    	<td>Action</td>
          </tr>
    <?php
    
    if(isset($_REQUEST['dealer_id']))
    {
    $dealer_id=$_REQUEST['dealer_id'];
    $qry="select * from product_table where dealer_id=$dealer_id";
    //echo $qry;
    $result = mysql_query($qry);
    
    if(mysql_num_rows($result)>0)
    {
    	while($row=mysql_fetch_array($result))
    	{
    		echo "<tr>";
    		echo "<td valign=top>". $row['product_id'] . "</td>";
    		echo "<td valign=top>". $row['product_name'] . "</td>";
    		echo "<td valign=top>". $row['description'] . "</td>";
    		echo "<td valign=top>". $row['cutout_price'] . "</td>";
    		echo "<td valign=top>". $row['price'] . "</td>";
    		echo "<td valign=top>". "<img border=1 height=115 width=92 src='uploads/" . $row['image'] . "'/>" . "</td>";
    		echo "<td valign=top>". $row['shipping_cost'] . "</td>";
    		echo "<td valign=top>". $row['shipping_detail'] . "</td>";
    		echo "<td valign=top>". $row['warranty'] . "</td>";
    
    
    if($row['status']=='Y') {
    $status = "Hide";
    } else {
    $status = "Show";
    }			
    
    		echo '<form name="status_update" action="manage_products.php" method="post">';
    		echo '<td valign="top"><input type="submit" value="'.$status.'" />';
    		echo '<input type="hidden" name="status" value="'.$row['product_id'].'" />';
    		echo '</td>';
    		echo '</form>';
    
    		echo "<td valign=top>"."<a href='modify_products.php?id=" . $row['product_id'] . "'/>  Modify </a>" . "</td>";
    		echo "</tr>";	
    	}
    }
    }	
    
    

     

    hi

     

    thanks thanks a lot. works perfect as needed.

     

    vineet

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