[Wolves] yet another php/mysql question

Iain Cuthbertson iain at cuth.eu
Fri Apr 13 23:03:09 UTC 2012


On 13/04/12 23:33, Wayne Morris wrote:
> been banging on at this simple thing for about 6 hours and can't get it!
> Sorry its not 'Linux' , but its a bit quiet in here of late so i might
> as well ;-)
>
> Got two scripts
> update.php - displays current record and allows you to change info -
> sends to
> record.php - sticks it in the database
>
> and another pair insert and save which create new records.
>
> been using them succesfully so I can send someone a link containing
>
> ../update.php?id=43&name=bob
>
> and it will pull up bob's record and allow edit and save.
>
> All well and good, but I wanted to create an on the fly link during
> the insert phase but of course at that point you don't know the ID
> until record created so decided to use
> email and dob as unique items.
>
> 1) or can you get id during the insert/save as a emailable variable -
> that's probably the easiest cos then other scripts untouched.?
>
> 2) what i have been mostly attempting to do is create a hyperlink
> containing email address and dob during insert phase eg
> ../update.php?email=xxx&dob=yyyy  so changed id to email ,  update.php
> receives this post data, opens the right record , got it set to
> display the correct ID.
> so id is set as $id - so update.php is populated with all the info
> needed as when using id and dob to populate.
>
> Can I get the bugger to save the record to that ID can I hell?
> The ID seems to be present as it appears in update.php, do I need to
> do anything special to get it posted to record.php?
>
> the bits that seem to matter:
>
> update.php
> echo "<form method=\"POST\" action=\"updaterecordtest.php\">";
> echo " <tr>";
> echo " <td width=\"35%\">Diver ID</td>";
> echo " <td width=\"65%\"><input type=\"text\" name=\"id\" size=\"35\"
> value=\"".$row["id"]."\"></td>";
>
> (shows correct ID)
>
>  record.php are:
> $id = $_POST["id"];
>
> and
>    if (isset($id))
>   {
>          $query = "UPDATE phonelist SET
>                                  coname = '$coname',
>                      address1 = '$address1' ,
>                     etc
>
>                          WHERE
>                                  id = '$id'
>          ";
>
> etc
>
> (nothing recorded)
>
> help!!
>
> cheers
>
>
>
>
>
>
>
>
> _______________________________________________
> Wolves LUG mailing list
> Homepage: http://www.wolveslug.org.uk/
> Mailing list: Wolves at mailman.lug.org.uk
> Mailing list home: https://mailman.lug.org.uk/mailman/listinfo/wolves

Hi Wayne,

I find that when a SQL query isn't doing as I expect it to, I echo out
the query and paste it into mysql client. Or preferably a GUI interface
such as SQLyog (windows program but work in wine).
Just to make sure that the query is being built as expected.

You might find that Your query is falling over at id = '$id'.
Might be better written as id = '" . mysql_escape_string($id) . "'

Hope this helps.

Cheers,
Iain



More information about the Wolves mailing list