Re: [PHP-DB] data is not entering in created database

2004-12-26 Thread Bastien Koert
error check it
mysql_query(INSERT INTO totalinfo (Username,Password) VALUES
('$loginusername','$loginpassword'))or die (mysql_error());

bastien

From: amol patil [EMAIL PROTECTED]
To: graeme [EMAIL PROTECTED],Jochem Maas 
[EMAIL PROTECTED], php-db@lists.php.net
Subject: Re: [PHP-DB] data is not entering in created database
Date: Sat, 25 Dec 2004 22:41:01 -0800 (PST)

hallo,
this was working well , submit is evaluating true, no errors, but
now data is not shown in databse table
?php
if($submit)
{
$dbh=mysql_connect (localhost, root) or die ('I cannot connect to 
the database because: ' . mysql_error());
mysql_select_db (dollar1_allinfo);

mysql_query(INSERT INTO totalinfo (Username,Password) VALUES 
('$loginusername','$loginpassword'));
}
?

what may be glitch


graeme [EMAIL PROTECTED] wrote:
I suspect that your $submit is not set up, try the following echo
statements before the if statement:
echo --$submit--;
echo --$_POST[submit]--;
amol patil wrote:
hallo ,

i have wriiten simple php script , below.
created databse dollar1_allinfo with table 'totalinfo'

but on clicking submit button ,

information entered is not entering in database.

also, echo statements are also not displaying after submit

if ($submit)
 {
 $db = mysql_connect(localhost,root);
 mysql_select_db(dollar1_allinfo,$db);
 mysql_query(INSERT INTO totalinfo (username,password,) VALUES 
('$loginusername','$loginpassword'));

 echo 'thank you';
 echo 'So Hurry Up';
 }
 ?





thank you.



-
Do you Yahoo!?
 Yahoo! Mail - Easier than ever with enhanced search. Learn more.




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] query is not executing data is not entering in created database

2004-12-26 Thread amol patil
hallo,
 
see below code.   query is not executing and data is not shown in table of 
database.after submit button hit.
 
how to evaluate  $submit true. have  Tried these statements before if statement
 
 echo --$submit--;

echo --$_POST[submit]--;

echoSubmit = $submit ;

but still query is not executing.
 
 
 
?php
 
if($submit)
{

 $dbh=mysql_connect (localhost, root) or die ('I cannot connect to 
the database because: ' . mysql_error());
mysql_select_db (dollar1_allinfo);

 mysql_query(INSERT INTO totalinfo (Username,Password) VALUES 
('$loginusername','$loginpassword'))or die (mysql_error());




}
?
 
 
suggest changes in above code to execute query.
 
 
thank you.







-
Do you Yahoo!?
 Yahoo! Mail - Easier than ever with enhanced search. Learn more.

Re: [PHP-DB] query is not executing data is not entering in created database

2004-12-26 Thread John Holmes
amol patil wrote:
hallo,
 
see below code.   query is not executing and data is not shown in table of database.after submit button hit.
 
how to evaluate  $submit true. have  Tried these statements before if statement
 
 echo --$submit--;

echo --$_POST[submit]--;
echoSubmit = $submit ;
but still query is not executing.
The reason people told you to put the above code is for troubleshooting. 
It's not going to fix your query. What do you actually see resulting 
from the above code before and after you hit your submit button? My 
crystal ball says you see this:



Submit =
Am I right?
?php
 
if($submit)
{

 $dbh=mysql_connect (localhost, root) or die ('I cannot connect to 
the database because: ' . mysql_error());
mysql_select_db (dollar1_allinfo);

 mysql_query(INSERT INTO totalinfo (Username,Password) VALUES 
('$loginusername','$loginpassword'))or die (mysql_error());
So if you see what I guessed above, then $submit is not set, so whatever 
code you have here not going to execute. Do you know how an IF 
conditional works? Do you know that if it evaluates to FALSE, then 
nothing within the conditional block is executed? Your query is probably 
fine, but the code is just never getting to it.

I could tell you to use $_GET['submit'] or $_REQUEST['submit'], but 
would you know why or where to use it?

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Undefined indicies

2004-12-26 Thread Peter Jay Salzman
Slightly off topic, I apologise.

Total newbie.  In many php DB tutorials I've seen, it's recommended to set
register_globals off, and error reporting to E_ALL.

When I looked at my system, register_globals was enabled and error reporting
was set to E_FATAL.  I changed them to the suggested values (off and E_ALL),
and all hell broke loose.  Clearly, I must not be very good at PHP yet.  ;)

First question:

register_globals is a matter of security, so that's definitely valuable to
turn off.  Is setting error reporting really useful if my aim is to become a
better PHP programmer?

I'm thinking along the lines of lint/splint, where this line of code in C:

   printf(hello world\n);

generates a useless warning because I'm not using printf()'s return value.
I'm wondering whether it's useful for a scripting language, like PHP, to
warn me when I use code like:


   if ( $_REQUEST['action'] == 'foo' )
  do_something;


when I don't access the URL with a ?action=foobar type request.

Should I change error reporting back to E_FATAL or is being this
compulsive about warnings good for me (and my security)?



Second question:

If being compulsive is good for me, what's the best way of handling
something like above?   From browsing php.net, I've thought of a few ways,
like a controlled suspension of compulsion:


   if ( @ $_REQUEST['action'] == 'foo' )
  do_something;

or, lord forbid:

   if ( isset($_REQUEST['action'])  $_REQUEST['action'] == 'foo' )
  do_something;

and also variations on a theme:

   if ( array_key_exists('action', $_REQUEST )
  $action = $_REQUEST['action'];

   if ( isset($action) )
  do_something;


Personal preference must play into this, but I'm wondering what more
experienced PHP programmers do.  My code is riddled with this kind of thing.

Thanks (and sorry for the long winded / slightly off-topic post!)

Pete

-- 
The mathematics of physics has become ever more abstract, rather than more
complicated.  The mind of God appears to be abstract but not complicated.
He also appears to like group theory.  --  Tony Zee's Fearful Symmetry

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D

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



Re: [PHP-DB] Undefined indicies

2004-12-26 Thread John Holmes
Peter Jay Salzman wrote:
Slightly off topic, I apologise.
Yeah, you should ask this on php-general@lists.php.net
Total newbie.  In many php DB tutorials I've seen, it's recommended to set
register_globals off, and error reporting to E_ALL.
Good recommendations. Setting the error reporting to E_ALL is for when 
you are developing your application. You'd want to turn off error 
reporting (and log them to a file, for example) when it goes live.

When I looked at my system, register_globals was enabled and error reporting
was set to E_FATAL.  I changed them to the suggested values (off and E_ALL),
and all hell broke loose.  Clearly, I must not be very good at PHP yet.  ;)
First question:
register_globals is a matter of security, so that's definitely valuable to
turn off.  
In your case, being a new programmer, yeah it's better to have it off. 
Note that having register globals ON makes it easier for you to 
introduce security issues into your code, especially if you're new. You 
can program security with it ON or OFF, it just takes some experience.

 Is setting error reporting really useful if my aim is to become a
better PHP programmer?
It is in my opinion. It'll help you during development to debug your code.
I'm wondering whether it's useful for a scripting language, like PHP, to
warn me when I use code like:
   if ( $_REQUEST['action'] == 'foo' )
  do_something;
when I don't access the URL with a ?action=foobar type request.
In that specific example it may not be helping a lot. That's because you 
know what's going on, though and you know why the value isn't defined. 
What if you're doing something like

if($something)
though. You're 100% sure $something is set to a known value so if it 
really wasn't (for whatever reason), without error reporting telling you 
it's undefined, you'd probably waste time troubleshooting something 
else. Just one example, but either way it's going to help.

If being compulsive is good for me, what's the best way of handling
something like above?   From browsing php.net, I've thought of a few ways,
like a controlled suspension of compulsion:
   if ( @ $_REQUEST['action'] == 'foo' )
  do_something;
or, lord forbid:
   if ( isset($_REQUEST['action'])  $_REQUEST['action'] == 'foo' )
  do_something;
Why lord forbid? This is how you should do it. I mean, since you do 
know what the issue is here, you could use the first method if you're 
afraid of isset() or something. I do it the second way, but yeah, it's 
personal preference.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] auto_increment

2004-12-26 Thread Ron Piggott
I have the auto_increment on one of my variables.  During the past few days
I have been doing testing on a live database and created several test
records which I now have deleted from my table.  Is there any way of setting
the auto_increment value to match the last correct number?  Ron

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



Re: [PHP-DB] auto_increment

2004-12-26 Thread Larry E . Ullman
I have the auto_increment on one of my variables.  During the past few 
days
I have been doing testing on a live database and created several test
records which I now have deleted from my table.  Is there any way of 
setting
the auto_increment value to match the last correct number?  Ron
You don't say what database application you're using, but if it's 
MySQL, you can change the auto increment value using:
ALTER TABLE tablename AUTO_INCREMENT = 1

That being said, you actually don't have to do this (and often 
shouldn't, really). Having gaps in your auto increment sequence 
shouldn't be a problem.

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


Re: [PHP-DB] Undefined indicies

2004-12-26 Thread Zareef Ahmed
On Sun, 26 Dec 2004 15:47:54 -0500, John Holmes
[EMAIL PROTECTED] wrote:
 Peter Jay Salzman wrote:
  Slightly off topic, I apologise.
 
 
 if ( isset($_REQUEST['action'])  $_REQUEST['action'] == 'foo' )
do_something;
 
 Personally I prefer the use of isset(), as it make sure that value is
set before doing any type of operation on it.  using @ is a dangerous
practice  as it just hide the  errors.
 And yes  error reporting ought to be E_ALL in development environment.

zareef ahmed



-- 
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net

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