Jump to content

Beeeeney

Members
  • Posts

    193
  • Joined

  • Last visited

Posts posted by Beeeeney

  1. What? the OP has the error code inside of a condition that waits for the edit button to be clicked.

     

    davidolson, the code is doing exactly what you have coded it to do, what are you expecting it to do?

     

    I skimmed the code over too quickly, it seems. Just saw that he said it's displaying those errors before they even submit everything.

  2. Ive cleared up the error by closing the parenthesis,

     

    Now i have the error:

     

    Notice: Use of undefined constant num_rows - assumed 'num_rows' on line 17
    
    
    Fatal error: Call to a member function fetch_assoc() on a non-object on line 21
    

     

    So I'm guessing that the query is failing in the first place??

     

    Those errors are detailing the EXACT problem. In plain English.

  3. Is this any better?

     

    
    
    <?php
    
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    
    //connect to database
    include_once('configuration.php');
    include_once('include/connect.php');
    
    
    $query = "SELECT id, product_id , amount FROM product_amount WHERE amount<=5.0000";
    
    $result = mysql_query($query) or die(mysql_error());
    
    
    
    if($result=num_rows>='2'
    $email='mymail@gmail.com';
    $subject = "LOW STOCK WARNING!";
    $message='One or more products are running low:\n\n';
    while($row=$result->fetch_assoc()) {
    $message="{$row["product_id"]}\n";
    }
    if(mail($email, $subject, $message)) {
    //mail successfully sent
    } else {
    //mail unsuccessful
    }
    }
    ?>

     

     

    I'm now getting an unexpected T_variable error near the bottom...

     

    Near the bottom?

    Is this any better?

     

    
    
    <?php
    
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    
    //connect to database
    include_once('configuration.php');
    include_once('include/connect.php');
    
    
    $query = "SELECT id, product_id , amount FROM product_amount WHERE amount<=5.0000";
    
    $result = mysql_query($query) or die(mysql_error());
    
    
    
    if($result=num_rows>='2'
    $email='mymail@gmail.com';
    $subject = "LOW STOCK WARNING!";
    $message='One or more products are running low:\n\n';
    while($row=$result->fetch_assoc()) {
    $message="{$row["product_id"]}\n";
    }
    if(mail($email, $subject, $message)) {
    //mail successfully sent
    } else {
    //mail unsuccessful
    }
    }
    ?>

     

     

    I'm now getting an unexpected T_variable error near the bottom...

     

    Near the bottom? Also you haven't closed a set of parenthesis.

  4. so, something like this?

     

    $result = mysql_query("SELECT id, product_id , amount FROM product_amount WHERE amount<=5.0000"); {
    die('Invalid query: ' . mysql_error());
    }
    

     

    As far as I'm aware, that's one big syntax error.

     

    Where your "die" command is concerned, you need to tell it to query the database and if it fails, then use "die" and display a MySQL error.

     

    <?php
    $result = mysql_query("SELECT id, product_id , amount FROM product_amount WHERE amount<=5.0000") || die("Invalid query:" . mysql_error());
    ?>
    

  5. Hi can someone help me, im new to php and was wondering what the structure of a php code would be for this question?

     

     

     

    write some PHP code to read the artist that the user entered into a variable, $a. After reading in the artist, write some PHP code to display a message which tells the user what artist they enteredNotepad write some PHP code to read the artist that the user entered into a variable, $a. After reading in the artist, write some PHP code to display a message which tells the user what artist they entered

     

    I am so confused and have to get this done by monday!!

     

    Thanks :)

     

    Just build a form that lets the user enter some data into a text area, and catch the information in a variable. Then echo the variable. Very simple to do, you could learn how to do it with a quick tutorial.

  6. Hello,

     

    I can't achieve what I am looking to do here:

     

     

    <html>
    <head>
    <title>PHP Weekend Challenge</title>
    </head>
    <body>
    <?php
    \\*if month = december and day = 23rd and time=19:00-23:59 echo "Good Evening, tomorrow is Christmas Eve!"
    or if month = december and day = 24th and time=19:00-23:59 echo "Good Evening, tomorrow is Christmas Day!"
    else echo "It's not Christmas so too bad - it's just another 7 day working week!"*\\
    ?>
    </body>
    </html>
    

     

    I'm a newbie so please assume I know nothing about PHP and provide as much explanation as you can for the solutions you give. I have read around on different websites and I find it exceptionally difficult to understand them because of my dyslexia and dyscalculia.

     

    Please advise :-)

     

    Thanks and Kind Regards,

     

    Beanie

     

    If you know literally nothing of PHP, you're gonna have a hard time understanding the answers that you get given here.

     

    Assign a variable to the current date, then use if() to echo something when it's a certain date, or whatever.

     

    Example:

     

    <?php
    $date = date(); //Put your date format in the parenthesis
    
    if ($date="") { //Again, where the quotes are, put what date you need it to be to echo whatever you need it to
    echo "Merry Generic Holiday!";
    } elseif ($date="") {
    echo "Happy other Generic Holiday";
    } else {
    echo "It's a normal day, have fun with your mediocre life";
    }
    ?>
    

     

    Or something. You can learn about date formats on PHP.net

  7. Just use an if.. else statement and use two variables. One for the single line of text and one for the text with the line breaks.

     

    Then if div size is whatever, then echo $variable1, else echo $variable2.

  8. [/font][/color]

     

    Still not understanding the issue. If you need three drop downs, you need the code for the three drop downs. What's it matter if they are in include files or not?

     

    *facepalm*

     

    I have the code for the three dropdowns. One is for Day, one is for Month and one is for Year. I have three separate bits on the form where a date needs to be entered. Date of Birth, Date of Issue and Date of Expiry.

     

    I need to validate them separately with Javascript, but I am using the same code for each instance that the date needs to be entered on the form. Now because of this, when the Javascript tries to validate, it won't be able to determine which one of the three is wrong.

     

    I need to have separate code for each date entry, but I wanted to know if there was a way to do it that didn't involve me repeating the code three times or making three separate include files.

  9. hello.

     

    How do i count how many pics in this array?

     

    $aUnits = array('pic1.jpg => '1', 'pic2.jpg => '2', 'pic3.jpg => '3');
    

     

    i tried this but its not working

     

    echo count($aUnits);
    

     

     

    thanks

    rick

     

    You were missing some quotation marks.

     

    $aUnits = array('pic1.jpg' => '1', 'pic2.jpg' => '2', 'pic3.jpg' => '3');
    

  10. You haven't exactly explained your issue.

     

    Sorry if I seem vague. I need to validate the three separate date entries with Javascript, to stop the form being submitted if the field returns as not selected. My code for generating the dropdowns for selecting Day, Month and Year is in a separate include file. Now, if I were to validate this part of the form with Javascript, it would try to validate all three different date entries with the one Javascript statement.

     

    Basically I need to have three different <select><?php generate dropdowns?></select>, so I can validate them separately, without having three different include files.

  11. Like this

     

    "menu.php":

     

    echo '<a href="/default.php">Home</a>

    <a href="/tutorials.php">Tutorials</a>

    <a href="/references.php">References</a>

    <a href="/examples.php">Examples</a>

    <a href="/about.php">About Us</a>

    <a href="/contact.php">Contact Us</a>';

     

     

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

    inclde-ex.php

    --

     

    <html>

    <body>

     

    <div class="leftmenu">

    <?php include 'menu.php'; ?>

    </div>

     

    <h1>Welcome to my home page.</h1>

    <p>Some text.</p>

     

    </body>

    </html>

     

    Have you tried putting PHP tags around your PHP code?

  12. Hi All,

     

    I've been trying to follow the tutorial from http://www.w3schools...hp_includes.asp but the example 2 displays the echo command on page rather then parsing the include file.

     

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

     

     

    echo 'Home Tutorials References Examples About Us Contact Us';

     

    Welcome to my home page.

     

    Some text.

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

     

     

    What could be wrong?

     

    Thanks in advance.

     

    Where are you including anything?

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