Jump to content

dabbsy

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dabbsy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've got a stored procedure, which takes values, and inserts into a table quite merrily.  I'm now trying to  extract the @p_information_id (derived from LAST_INSERT_ID() in the stored procedure).  The PHP is shown below. $query = "CALL sp_ins_application ($an, $et, '$en', '$av', '$dv', '$au', '$sp','$not', @p_information_id, @p_error)"; $result = mysql_query($query) or die ("ERROR: Query failed: " . mysql_error()); How do I use PHP to extract the information held in these OUT parameters. If it helps, the full SP is shown below ( I know the error checking isn't particularly sophisticated, but it seems to work!). DROP PROCEDURE IF EXISTS sp_ins_application; DELIMITER // CREATE PROCEDURE sp_ins_application( /* insert a new application and then pass back the new id. */ IN p_app_id MEDIUMINT, IN p_environment_type_id SMALLINT, IN p_environment_name VARCHAR(50), IN p_app_version VARCHAR(50), IN p_db_version VARCHAR(25), IN p_application_url VARCHAR(200), IN p_sql_port VARCHAR(40), IN p_notes VARCHAR(250), OUT p_information_id MEDIUMINT, OUT p_error VARCHAR(200) ) BEGIN /* Declarations section */ DECLARE exit handler for sqlexception SET p_error := 'An error has occured trying to call sp_ins_application - either database or data issues'; INSERT INTO information (app_id, environment_type_id, environment_name, app_version, db_version, application_url, sql_port, notes) VALUES ( p_app_id, p_environment_type_id, p_environment_name, p_app_version, p_db_version, p_application_url, p_sql_port, p_notes); IF ROW_COUNT() = 0 THEN SET p_error = 'Unable to insert new application.'; ELSE SET p_error = 'OK'; SELECT LAST_INSERT_ID() INTO p_information_id; END IF; END; // delimiter ; Thanks for any help anyone can offer!
  2. I'm writing some code to allow a user to do some updates. To do this, I want to return all the potential options, but display the existing value in a select list.  I can use the following to restore all the potential values, but assuming the os_id was 3 say (AIX in this case), how do I ensure that AIX is the value that is displayed at the top of the list? Hope someone can help, J <td align="left">OS Type:</td><td><select name="os_type"> <?php  require_once ('./../mysql_connect.php'); $query = "SELECT os_id, os_type FROM os_type"; $result = mysql_query ($query); // Run the query. while ($row = mysql_fetch_array ($result, MYSQL_NUM)) { echo "<option value=\"$row[0]\""; echo ">$row[1]</option>\n'"; } ?> /></td>
  3. The problem I'm having is with the syntax to drop into the form area - i.e. what I need to put into that value "" field.  I just can't work out how to get it into the form  :-[
  4. This is probably bread and butter to you all, but I'm new to php, so you'll have to bear with me!!! I've got a form which has several text areas in, which is defined within a form (a small part of the code is shown at the bottom) - I can happily get this to populate the database with new information using POST  - if (isset($_POST['submit'])).  The next stage is for the user to select an application name from a list (pulled back from the database) and include it in a form so the user can select from it.  The code for this is below.  Both pieces work individually, but I can't get the list of application to be displayed and work within a form.  Can anyone help with the syntax or am I approaching it in the wrong way? [b]Code to pull back the application name[/b] echo '<p><b>Select application:</b> <select name="app_name[]" size="3">'; $query = "SELECT application_id, application_name FROM contacts ORDER BY application_name ASC"; $result = mysql_query ($query); // Run the query. while ($row = mysql_fetch_array ($result, MYSQL_NUM)) { echo '<option value=\"$row[0]\"'; echo ">$row[1]</option>\n'"; } echo '</select></p>'; mysql_free_result ($result); // Free up the resources. [b]Form code[/b]  (only one text field shown to avoid pasting a load of code) <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">     <p>         Application Name:<br />       <input type="text" name="app_name" size="25" maxlength="25" value="" />     </p>     <p>     <p>       <input type="submit" name="submit" value="Submit!" />     </p> </form> Hope someone can help! Thanks, J
×
×
  • 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.