php-general Digest 2 Oct 2012 06:52:47 -0000 Issue 7990
Topics (messages 319319 through 319323):
Re: php can't insert data mysql table
319319 by: Tim Dunphy
Re: Basic Statistics
319320 by: Sebastian Krebs
Good tutorial for compiling last PHP with Apache support from source
319321 by: Alan Hoffmeister
319322 by: Rodrigo Silva dos Santos
problem with my login script
319323 by: Thomas Conrad
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
>
> I think the comment about your "cannot insert query" was because it really
> did not make sense. Once truly cannot "insert a query". Since you ask
> tho, a more approp message might be
> "Insert query failed to execute.<br>Error returned was " . mysqli_error()
> . "<br>Query was $q"
>
> As for your index issue - you are using an autoincrement(?) field as the
> primary key. Is this related to another record in your db? If not, why
> even have the primary key?
>
> Hey! I really like your error message. Borrowing it! :) Yes I am now using
auto_increment, and that's what seemed to solve my issue. Looks like a
simple omission in forgetting to use auto_increment and using primary key.
I usually know better. I'll blame this one on the clonopin. lol
thank you
tim
On Mon, Oct 1, 2012 at 12:30 PM, Jim Giner <jim.gi...@albanyhandball.com>wrote:
> On 10/1/2012 12:20 PM, Tim Dunphy wrote:
>
>> hey thanks guys adding debugging info worked.
>>
>> Actually it was mysqli_error() providing me with a specific error of where
>> the problem was.
>>
>> Cannot insert query:Duplicate entry '0' for key 'PRIMARY'
>>
>> This is the data in the table
>>
>> mysql> select * from guitarwars;
>> +----+---------------------+--**-----------------+-------+----**
>> ---------------+
>> | id | date | name | score | screenshot
>> |
>> +----+---------------------+--**-----------------+-------+----**
>> ---------------+
>> | 0 | 2012-10-01 11:55:45 | Tommy Tutone | 2442 |
>> bg_titlestrip.jpg |
>> | 1 | 2012-10-01 08:34:18 | Dunphy | 20000 | proof.jpg
>> |
>> | 2 | 2012-10-01 00:25:53 | ray davies | NULL | 2241
>> |
>> | 3 | 2008-04-22 14:37:34 | Paco Jastorius | NULL | NULL
>> |
>> | 4 | 2008-04-22 21:27:54 | Nevil Johansson | NULL | NULL
>> |
>> | 5 | 2008-04-23 09:12:53 | Belita Chevy | NULL | NULL
>> |
>> | 6 | 2008-04-23 14:09:50 | Kenny Lavitz | NULL | NULL
>> |
>> | 7 | 2008-04-24 08:13:52 | Phiz Lairston | NULL | NULL
>> |
>> | 8 | 2008-04-25 07:22:19 | Jean Paul Jones | NULL | NULL
>> |
>> | 9 | 2008-04-25 11:49:23 | Jacob Scorcherson | NULL | NULL
>> |
>> +----+---------------------+--**-----------------+-------+----**
>> ---------------+
>>
>>
>> This was the query I was using:
>>
>> $query = "INSERT INTO guitarwars (date, name, score, screenshot) VALUES
>> (NOW(), '$name', '$score', '$screenshot')";
>>
>> It seems to be inserting a default value of 0 since the id is not being
>> specified and that's when I realized that I had failed to auto_increment
>> the id column. D'oh! So once I did that everything worked like a charm.
>>
>> @Ken
>>
>>> First -- NEVER post code with your database username/password. Since you
>>>
>> did, change your db password immediately.
>>
>> Well actually I did not. Did you really think 'secretsauce' was my
>> password? :) But I guess you're right in that this may be a little
>> ambiguous when seeking advice in lists so from now on I will take your
>> advice on making login information unambiguously fake in the form of
>> user='xxxx' and password='xxx'.
>>
>> @Stuart
>> But take note of what everyone else is saying. You should be getting the
>> error message when this happens which will tell you exactly what the
>> problem is, above and beyond "Cannot insert query" (which, btw, makes no
>> sense at all :)).
>>
>> Ok well I'm using an 'insert' query so I'm not sure why you say that this
>> makes no sense at all. :)) If you don't mind giving this n00b advice what
>> would be a better/more accurate error message?
>>
>> They take away from this for me was.. don't skimp on the error messages!
>> The one I got was so clear that fixing the problem was easy at that point.
>>
>> But thanks again guys.. this list has been an indispensable source source
>> of wisdom on my journey in learning PHP.
>>
>> Tim
>>
>>
>> Thanks again guys,
>> Tim
>>
>>
>>
>> I think the comment about your "cannot insert query" was because it
>> really did not make sense. Once truly cannot "insert a query". Since you
>> ask tho, a more approp message might be
>> "Insert query failed to execute.<br>Error returned was " . mysqli_error()
>> . "<br>Query was $q"
>>
>> As for your index issue - you are using an autoincrement(?) field as the
>> primary key. Is this related to another record in your db? If not, why
>> even have the primary key?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
GPG me!!
gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
--- End Message ---
--- Begin Message ---
Hi,
Something like http://php.net/ref.stats ?
Regards,
Sebastian
Am 01.10.2012 18:37, schrieb George R Smith:
Can anyone recommend a basic php stat package, easy to install and use.
Just basic stuff like mean, median, range std dev etc
thanks
george
--- End Message ---
--- Begin Message ---
Hello fellows,
Does any one know a good guide for noobs to compile last PHP with
Apache support from source code? I was planning to use Ubuntu 11.10.
Already googled it but could only find old references that cannot be
used anymore.
Thanks.
--
Att,
Alan Hoffmeister
--- End Message ---
--- Begin Message ---
Hello Alan.
Did you ever compile any application?
It's relatively simple. Generaly, You just have to:
Certify you have the minimum tools to compile a program (e.g apt-get install
build-essentials)
Cd to the php sources directory (i'm assuming you have allready downloaded them)
As root, run:
# ./configure
Select the options that applies to your needs, them
# make && make install
That should do the trick for you
Enviado por Samsung Mobile
Alan Hoffmeister <alanhoffmeis...@gmail.com> escreveu:
Hello fellows,
Does any one know a good guide for noobs to compile last PHP with
Apache support from source code? I was planning to use Ubuntu 11.10.
Already googled it but could only find old references that cannot be
used anymore.
Thanks.
--
Att,
Alan Hoffmeister
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I'm currently learning php and as a challenge, I'm creating a login
script using text files to store the information (until I learn how to
handle databases with php).
The problem I'm having is the if statement in my while loop is only
evaluated on the last iteration of the while loop, so its only
comparing the last username in the file and no others.
Heres the code:
<?php
session_start();
$users = file("../inc/users.inc.php");
if($_POST['username'] && $_POST['password']){
if(ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$",
$_POST['username'])){
while(list($id ,$username) = each($users)){
if($_POST['username'] == $username){
$_SESSION['logged_in'] = 1;
$_SESSION['username'] =
$username;
}
}
if($_SESSION['logged_in'] != 1){
$error = "2";
}
}else{
$error = "4";
}
}else{
$error = "3";
}
if($error){
header("Location:
http://koopasforever.com/scripts/login.php?error=$error");
}else{
header("Location: http://koopasforever.com/");
}
?>
I have checked all my variables and they all contain the proper information
Some help would be greatly appriciated, Thanks
--- End Message ---