Jump to content

anfo

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Posts posted by anfo

  1. is it possible to put data from a sql query into text boxes for doing an update query?

     

    what i'm doing is trying to change an address on the same page as I display results from a query to get the person's details.

     

    e.g. retrieve joe blogs address 12 smith st,

     

    have these display in text fields

     

    then change it to 21 jump st

     

    then click on a submit button which runs an UPDATE SET query.

     

    any help gratefully recieved

  2. and on the page you redirect it to try this....

     

    if(isset($_POST['submitted']))

    {

    //do something

    echo '<p> data received</p>';

    {

    else

    {

    echo '<p>Page not submitted</p>';

     

    this bit of code tests whether the information has been sent to the new page or else it shows a message Page not submitted.

     

    the //do something is a comment but where you see the data received line this is where you do something with the information.

     

  3. Hi Guys,

    I am having a problem with my sql code. I get an error message "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Smith St , suburb = Sydney , pcode = 2000 , ' at line 3.

     

    I have tried the code below with the keyword AND in placde of the comma's, as well as AND before  mfirstname, they both produce the same error. Yes I am trying to integrate this code with php.

     

    php version : 5.2.6

    sql version: 5.0.51b

    on windows xp.

     

    I am not sure if I am trying to update too many columns at a time or what.

     

    any help would be appreciated.

     

    Thanks and Regards

    Anfo

     

    here is my sql code.

     

    $query = "UPDATE members SET msurname = " . mysql_real_escape_string(stripslashes($_POST['msurname'])) . " ,

        mfirstname = " . mysql_real_escape_string(stripslashes($_POST['mfirstname'])) . " ,

      address = " . mysql_real_escape_string(stripslashes($_POST['address'])) . " ,

      suburb = " . mysql_real_escape_string(stripslashes($_POST['suburb'])) . " ,

      pcode = " . mysql_real_escape_string(stripslashes($_POST['pcode'])) . " ,

      home = " . mysql_real_escape_string(stripslashes($_POST['home'])) . " ,

        work = " . mysql_real_escape_string(stripslashes($_POST['work'])) . " ,

      mobile = " . mysql_real_escape_string(stripslashes($_POST['mobile'])) . " ,

      email = " . mysql_real_escape_string(stripslashes($_POST['email'])) . "

      WHERE member_id = $row[0] LIMIT 1";

     

     

  4. here's a snippet of code, that I just can't get to work and still being a fledgling programmer can't figure out why not.....

     

    I am using PHP version 5.2.6, mysql version is 5.0.51b, on a win xp pro platform. If antone can help I'd be extremely grateful. Thanks Anfo.

     

    <form action="title_search.php" method="get">
    <fieldset>
    <p><strong>Title: </strong><input type="text" name="title" maxlength="60"/></p>
    <input type="button" name="submit" value="Search" />
    <input type="hidden" name="submitted" value="TRUE" />
    </fieldset>
    </form>
    
    <?php
    // Connect to the db.
    require_once ('./includes/dbconn.php');
    
    // Make the query.
    $query = "SELECT title FROM `books` WHERE `title` LIKE $_GET['title']";
    
    // Run the query.		
    $result = @mysql_query ($query); 
    
    // If query runs alright, display the records.
    if ($result) 
    { 
    
    // Table header.
    echo '<table align="center" cellspacing="0" cellpadding="5">
    <tr><td align="left"><b>Title</b></td></tr>';
    
    // Fetch and print all the records.
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) 
    	{
    	echo '<tr><td align="left">' . $row['title'] . '</td></tr>';
    	}
    
    echo '</table>';
    ?>

     

    (edited to add

    
    

    tags)

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