Re: Solution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tedd

I had four tables.  name, (fname, lname) address(street, town, state, zip), 
contact(phone, fax, email), comments (comments).

It was done this way because it is strictly a learning exercise.  I had 
never created a DB with multiple tables, so I wanted to be able to contruct 
one using foreign keys, and be able to insert and retrieve from it.

But the experiment continues.  For whatever reason, scripts to query a DB 
that I have used for years are not working.  I am thinking it has something 
to do with that I switched engines to innodb.

So the lesson continues.

Gary

"tedd" <tedd.sperling@xxxxxxxxx> wrote in message 
news:p06240804c7ea44eb9789@[192.168.1.102]...
> At 6:04 PM -0400 4/12/10, Gary wrote:
>>For those that were looking to see a solution, this is what I have come up
>>with.  It was pointed out on another board (MySQL) that inserting multiple
>>in one script is probably prohibited because of security reasons.
>>
>>What I did was open the connection, insert into the table, close the
>>connection, close the php script, then start over again.  This is the 
>>code:
>>
>>$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting 
>>to
>>MySQL server');
>>
>>$query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";
>>
>>$result=mysqli_query($dbc, $query)
>>or die('Error querying database.');
>>
>>mysqli_close($dbc);
>>?>
>>
>><?php
>>
>>$dbc=mysqli_connect('localhost','root','','test')or die('Error connecting 
>>to
>>MySQL server');
>>$query="INSERT INTO address (street, town, state,
>>zip)"."VALUES('$street','$town','$state','$zip')";
>>
>>$result=mysqli_query($dbc, $query)
>>or die('Error querying database.');
>>
>>mysqli_close($dbc);
>>
>>?>
>>
>>It seems a little redundant for PHP, however it seems to work.
>>
>>Thank you to everyone that responded.  If by the way someone sees an issue
>>with this solution, I would love to read it.
>>
>>Gary
>
> Gary :
>
> It not only looks redundant, but why two tables?
>
> Why not "customers" or "users" or "subscribers" like so:
>
> include(opendb.php);
>
> $query="INSERT INTO users (first_name, last_name, street, town, state, 
> zip)
> VALUES('$first_name', '$last_name', $street', '$town', '$state', '$zip')";
>
> $result=mysqli_query($dbc, $query) or die('Error querying database.');
>
> include(closedb.php);
>
> I don't see any reason to separate the attributes of the person into two 
> different tables. Why do that?
>
> Cheers,
>
> tedd
>
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> __________ Information from ESET Smart Security, version of virus 
> signature database 5025 (20100413) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
> 



__________ Information from ESET Smart Security, version of virus signature database 5025 (20100413) __________

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux