Jump to content

Irish_Dave

New Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Irish_Dave

  1. Hi Everyone

    I am having a few issues with my website. I have developed in on my xampp local host and it works ok but when I upload the files and try to renew a membership using stripe I get the following messages.

    Warning: session_start(): Cannot start session when headers already sent in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/inc/settings.php on line 2 

    Warning: Cannot modify header information - headers already sent by (output started at /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php:1) in /customers/a/d/f/mywebsite.co.uk/httpd.www/mywebsite/procedures/payments/charge.php on line 141

    I have some includes that appear on every page. This is the bootstrap.php file. This file holds the settings.php which connects to my database and other function files.

    In this settings page I call the session_start() php function and then connect to my database.

    I call the bootstrap.php file on every page to there for call the session_start() on every page.

    I am using sessions alot so is this the right thing to do?

    I have attached the renew_membership payment page which holds the form. The user fills out the payment page and the form data gets sent to a script called charge.php which uses the stripe objects to make the payment. I then want to do a redirect to the paymentSuccess.php page to output to the user that the payment was made successfully. This is where the issues arrise. I have split the charge file into 3 screen shots so it is more readable.

    Hope someone can help me.

    Thanks a lot

    David

     

     

     

     

     

     

     

     

     

     

     

     

    bootstrap_php.jpg

    charge_php_1.jpg

    charge_php_2.jpg

    charge_php_3.jpg

    paymant_success.jpg

    renew_payment_code.jpg

    renew_payment_form.jpg

    settings_php.jpg

  2. Hi everyone, I have managed to resolve the issue of making my html form controls reflect what i am reading back from my SQL database.

     

    It was rather straight forward in the end but it was more by accident rather than anything else because I am not understanding quite why it works.

    I made the following variable access the associative array as shown below:

     

                        <?php $catch_position = $sel_subject['position']; ?>

    <?php $catch_visible = $sel_subject['visible']; ?>

     

    There are two issues confusing me :

     

    1) is the fact that I put the line of code before the function call $sel_subject = get_all_subjects() surely they should be placed after the function call but when I do that it doesn't work.

     

    2) Why could I not access the associative array directly.

     

    A real scratch your head moment. Glad it works but depressing the fact the logic doesn't make sense.

    If anyone has come across this before and knows why then I would love you to share it with me.

     

    Thanks again to everyone who offered help/knowledge in this problem

    17999_.php

  3. Hi everyone.

    To try and  make it a bit more clear what I am seeing, I have attached a screen dump of what i get in my browser and of my SQL database.

     

    So just to summaries my problem again: I am running an sql query on my database returning a data set.

    I am using this data set to create my navigation on the left of my browser.

    When I select a menu subject I get the edit_page.php showing the Subject/Menu selected in a text field but I want the Position value reflected in the html select control and the visibility No/Yes (1/0 numeric values) reflected in the radio buttons. I can  not get the html select or radio buttons reading the php associative array ($sel_subject['position'] or $sel_subject['visible']).

    How can I read $sel_subject['menu_name'] in to the input text field but not the other two elements of the associative array.

    Very confusing.

    post-132971-13482403394645_thumb.jpg

    post-132971-13482403394903_thumb.jpg

    17993_.php

  4. Hi CPD.

    Thanks for the help, i added the code and it returned an array with all the sql data set in it. So this must prove the  funtion is returning a data set, or also known as a resource as I have read in other sites. So it just begs the question why will my html select and radio controls not reflect the values in the associative array?? Still confused.

     

    Thanks to everyone so far for the input, it all helps just not got it working yet.

  5. Hi algidDes702.

     

    Thanks for taking the time to look in to my problem. Thanks for the debugging tips. I am very new like I said to php. I have applied what you said, and echoed what was returned from the $sel_subject = get_all_subjects()

    which basically runs a query on the sql database. I got a"Resource id #14" returned not an array like i was expecting. Not sure what this means.

    I also echoed $subject_count = mysql_num_rows($sel_subject); and I got 4 returned which matched what i would expect if I had an array returned from the get_all_subjects() function.

     

    I have attached the functions and connection code that are needed for the sql query.

     

    Not sure what to do now? I suppose I need to verify absolutely the contents of the $sel_subject, some how see whats in the variable.

     

    17985_.php

    17986_.php

    17987_.php

    17988_.php

  6. Hi dragon_sa, and thank you for taking the time to read my post.

     

    I am quite sure the php function get_all_subjects() returns an array to the php variable $sel_subject

    because the php code outputs the menu name selected to the input text box.

     

                                                <p>Subject Name:

    <input type="text" name="menu_name" value="<?php echo

                                                          $sel_subject['menu_name']; ?>" id="menu_name"/>

          </p>

     

    I then replaced the $sel_subject['menu_name'] with $sel_subject['position'] to see if the position was outputted to the text box and it was.

    I have attached the functions.php along with the connection, constants, and edit_subject.php to see if that would make what I am trying to solve any clearer.

     

    So in summary, I can access the array elements and output them to a text field but not to a select control or radio button.

                                       

    17977_.php

    17978_.php

    17979_.php

    17980_.php

  7. Hi everyone.

    I am David and I am new to web design and php. I am following a Lynda.com tutorial on php and sql.

    I have reached a certain point in the tutorial where I am reading values back from my database in to a php variable. The variable is holding an array data type and I am accessing the element within the array.

     

    I want a HTML select control and 2 radios buttons to reflect the values in the database.

    Therefore the Select control should read a numeric value of type int and the radio buttons are reflecting either a 1 or a 0.

     

    Firstly the code for the Select control uses a for loop to count the array elements and load the count into the Select control. The example uses php mixed with html. The for loop will count the number of element and add a number to the select control. The an If statment is used to make a decision if the count variable equals the value in the array element $sel_subject['position'] then select that value. This does not happen, and I can not seem to get it to work.

     

                                              <p>Position:

    <select name="position">

    <!--use a php block so as to use some php variables -->

    <!--Use these variables with the get_all_sublects function. -->

    <!-- This function will return all the dataset -->

    <?php

    $sel_subject = get_all_subjects();

    //Then use the mysql fuction to retuen the numberic value of all the rows.

    $subject_count = mysql_num_rows($sel_subject);

    //$subject_count + 1 becauce we are adding a subject

    for($count=1; $count <= $subject_count+1; $count++)

    {

    echo "<option value=\"{$count}\"";

     

    if ($sel_subject['position'] == $count)

    {

    echo " selected";

    }

     

    echo ">{$count}</option>";

    }

    ?>

    </select>

    </p>

     

    Secondly the radio buttons do something similar in that i want them to reflect the value in the array element. If a 1 then True and so be checked or 0 and so false and so be unchecked.

     

                                                <p>Visible:

     

    <input type= "radio" name= "visible" value= "0"

    <?php if ($sel_subject['visible'] == 0)

    {

    echo 'checked=" checked"';

    }

    ?>

    >No</input>

     

    <input type= "radio" name= "visible" value= "1"

    <?php if ($sel_subject['visible'] == 1)

    {

    echo 'checked=" checked"';

    }

    ?>

    >Yes</input>

    </p>

     

    Again this doesn't work either. So in summary, I cant get the php code to affect the html form controls and relay the stored data to the user.

    I have been racking my brain for days and getting no where. Please can anyone help me with this.

     

    I would be very grateful.

    All the best Irish_Dave

     

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