Jump to content

dcro2

Members
  • Posts

    489
  • Joined

  • Last visited

    Never

Posts posted by dcro2

  1. [!--quoteo(post=352665:date=Mar 7 2006, 06:04 PM:name=master82)--][div class=\'quotetop\']QUOTE(master82 @ Mar 7 2006, 06:04 PM) [snapback]352665[/snapback][/div][div class=\'quotemain\'][!--quotec--]$sql = mysql_query("SELECT * FROM Users");

    $finalnumber = intval($_POST['sales']) * (0.75);
    $finalnum = ($finalnumber + intval($row['salestodate']));
    [/quote]

    In this line:
    $finalnum = ($finalnumber + intval($row['salestodate']));
    you haven't fetched the results from:
    $sql = mysql_query("SELECT * FROM Users");

    You need to use:
    [code]$sql = mysql_query("SELECT * FROM Users");
    $row = mysql_fetch_assoc($sql);

    $finalnumber = intval($_POST['sales']) * (0.75);
    $finalnum = ($finalnumber + intval($row['salestodate']));[/code]
  2. [!--quoteo(post=352656:date=Mar 7 2006, 05:33 PM:name=sjones)--][div class=\'quotetop\']QUOTE(sjones @ Mar 7 2006, 05:33 PM) [snapback]352656[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    $record = mysql_fetch_row($result);
    //...
    <td><img src='http://uswebproducts.com/country_savings/uploads/$record'>
    [/quote]
    mysql_fetch_row returns an array, that's why the image displayed is:
    "http://uswebproducts.com/country_savings/uploads/Array"
    Use $record[0...1...2...etc] according to field order

    It would be better to use mysql_fetch_array or mysql_fetch_assoc in your case.

  3. You could:

    [code]$sql = mysql_query("SELECT * FROM Users WHERE user_id = '$userid'"); //I'm just guessing about the user_id.
    $row = mysql_fetch_assoc($sql);

    $finalnumber = intval($_POST['sales']) * (0.75);
    $finalnumber = $finalnumber + intval($row['num_field']);

    $sql = mysql_query("UPDATE Users SET num_field = '$finalnumber'");
    if($sql) {
      echo "Success!";
    } else {
      echo "Failed...";
    }[/code]
    Of course, replace 'num_field' with the field in your database.
  4. You could use substr() to limit the characters to 50, 100, etc.

    [code]string substr ( string string, int start [, int length] )[/code]
    So, I'm guessing in your case it would be:

    [code]$message = substr($message, 0, 50);[/code]
    For viewing only text, you could use the strip_tags() function

    [code]string strip_tags ( string str [, string allowable_tags] )[/code]
  5. Should be that you are checking for 'submit' to be empty, while your submit button's name is 'vendor_id':

    [code]if(empty($_POST['submit'])) { //If the submit button has not been set we will echo a welcome statement[/code]

    [code]<input name='vendor_id' type='submit' value='Remove'>[/code]
    So.. it is [b]always[/b] trying to remove the vendor_id 'Remove'...
    It should be trying to remove $_POST['cat_id']
  6. Well, first, are you sure your server has PHP installed? You might want to check that before anything.
    And, second, are you using $_POST to get the values before this code?
    Thirdly, you don't need to do $var = "$var", that's just wasting milliseconds :P
  7. You copied the else two times, use this:

    [code]include ('../connections/mysql_connect.php');
    if(empty($_POST['submit'])) {
        echo "<span class='content_blank'><strong>Welcome....</strong><BR></span>
              <span class='content_blank'>You can enter a new Vendor by selecting the category that they belong<BR></span>
              <span class='content_blank'>and entering the name of the new vendor</span><BR><BR>";
    }else{
        if(!empty($_POST['cat_id']) & !empty($_POST['name'])) {
            $qry = mysql_query("INSERT INTO vendors (cat_id,vendor_name) VALUES ('".$_POST['cat_id']."','".$_POST['name']."');");
            if($qry) { echo "<span class='content_blank'><strong>New vendor has been added</strong></span>"; }
            else { echo "<span class='content_blank'><strong>Error inserting new vendor</strong></span>"; }
        } else {
            echo "<span class='content_blank'><strong>Error: something was left blank</strong></span>";
        }
    }

    echo "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>
    <tr>
    <td>
       <span class='content_blank'>Please choose a category and type in the name for the new vendor.</span><br><br>
       <form method='post' action='csmag_admin.php?c=add_vendor'>
       <select name='cat_id'>
       <option>- Please select one -</option>\n";
       $qry = mysql_query("SELECT * FROM categories;");
       while($rows = mysql_fetch_assoc($qry)) {
           echo "<option value='".$rows['cat_id']."'>".$rows['cat_name']."</option>\n";
       }
       echo "</select>
       <input name='name' type='text' size=20>
       <input name='submit' type='submit' value='Submit'>
       </form>
    </td>
    </tr>
    </table>";[/code]
  8. The <select>'s options have the cat_id as the value when you choose them, therefore you don't need to get it out of the database when you are inserting it. What you actually see in the select is the cat_name.
    When you insert the new vendor, yes it will auto increment the vendor_id.

    PS: the form needs to be submitted to [b]'cs_mag.php?c=add_vendor'[/b] not [b]'cs_mag?c=add_vendor.php'[/b]
  9. Um, well something like this?:

    [code]if(empty($_POST['submit'])) {
        echo "<span class='content_blank'><strong>Welcome....</strong></span>";
    } else {
        if(!empty($_POST['vendorid']) & !empty($_POST['name'])) {
            $qry = mysql_query("INSERT INTO vendors (cat_id,vendor_name) VALUES ('".$_POST['vendorid']."','".$_POST['name']."');");
            if($qry) { echo "<span class='content_blank'><strong>New vendor has been added</strong></span>"; }
            else { echo "<span class='content_blank'><strong>Error inserting new vendor</strong></span>"; }
        } else {
            echo "<span class='content_blank'><strong>Error: something was left blank</strong></span>";
        }
    }

        } else {
            echo "<span class='content_blank'><strong>Error: something was left blank</strong></span>";
    echo "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>
    <tr>
    <td>
       <span class='content_blank'>Please choose a category and type in the name for the new vendor.</span><br><br>
       <form method='post' action='csmag_admin.php?c=add_vendor'>
       <select name='vendorid'>
       <option>- Please select one -</option>\n";
       $qry = mysql_query("SELECT * FROM categories;");
       while($rows = mysql_fetch_assoc($qry)) {
           echo "<option value='".$rows['cat_id']."'>".$rows['cat_name']."</option>\n";
       }
       echo "</select>
       <input name='name' type='text' size=20>
       <input name='submit' type='submit' value='Submit'>
       </form>
    </td>
    </tr>
    </table>";[/code]
×
×
  • 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.