Re: [PHP] PhP / MySQL problem
I'm using FF. But it asks to confirm the change of password of my MySQL users. If I comment the php/mysql lines in the .php files, I do not have such a pop-up. Ludovic André wrote: > > >> Hi, >> >> I created a form asking username, password, country, etc. >> On the submit of this form I make a sql connection and update the >> database, >> add the user. >> >> The problem is that whenever the field 'password' is filled in, >> "it" (I don't know what) is asking to confirm the change of the password. >> >> I made a printscreen to clarify : >> >> http://matthew16.free.fr/sql.jpg >> >> This is what I get when I try to submit the form and I filled in field >> password. >> The users displayed in the pop-up are the MySQL users. > This has nothing to do with your PHP/MySQL, but it's a feature of your > browser (you're using Firefox, aren't you?) > Did you use the functionnality "remember the password" ? If so, then the > users listed here are the ones for whom you wanted to remember the > password. Firefox tries to be smart in this case: if you're updating the > password, it asks you which user has changed... > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- View this message in context: http://www.nabble.com/PhP---MySQL-problem-tf4349742.html#a12394801 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PhP / MySQL problem
On Wed, August 29, 2007 2:03 pm, debussy007 wrote: > I created a form asking username, password, country, etc. > On the submit of this form I make a sql connection and update the > database, > add the user. > > The problem is that whenever the field 'password' is filled in, > "it" (I don't know what) is asking to confirm the change of the > password. > > I made a printscreen to clarify : > > http://matthew16.free.fr/sql.jpg > > This is what I get when I try to submit the form and I filled in field > password. > The users displayed in the pop-up are the MySQL users. > > The php/sql code is the following : > > mysql_select_db("mydb", $link) or die(mysql_error()); > $query = > "INSERT INTO members > (username,password,date_of_birth,e_mail,country) > VALUES ('". > $_POST['username']."','". > $_POST['password']."','". > $_POST['dateofbirth']."','". > $_POST['email']."','". > $_POST['country']."')"; > $result = mysql_query($query, $link) or die($query . " - " . > mysql_error()); I believe that browser is configured to "remember" passwords (BAD IDEA!!!) and is asking you to confirm the change for its local memory. I am 100% certain that whatever it is, it ain't PHP doing it. :-) -- Please vote for this great band: http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES Requires email confirmation. One vote per day per email limit. Obvious ballot-stuffing will be revoked. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PhP / MySQL problem
Hi, I created a form asking username, password, country, etc. On the submit of this form I make a sql connection and update the database, add the user. The problem is that whenever the field 'password' is filled in, "it" (I don't know what) is asking to confirm the change of the password. I made a printscreen to clarify : http://matthew16.free.fr/sql.jpg This is what I get when I try to submit the form and I filled in field password. The users displayed in the pop-up are the MySQL users. This has nothing to do with your PHP/MySQL, but it's a feature of your browser (you're using Firefox, aren't you?) Did you use the functionnality "remember the password" ? If so, then the users listed here are the ones for whom you wanted to remember the password. Firefox tries to be smart in this case: if you're updating the password, it asks you which user has changed... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PhP / MySQL problem
Hi, I created a form asking username, password, country, etc. On the submit of this form I make a sql connection and update the database, add the user. The problem is that whenever the field 'password' is filled in, "it" (I don't know what) is asking to confirm the change of the password. I made a printscreen to clarify : http://matthew16.free.fr/sql.jpg This is what I get when I try to submit the form and I filled in field password. The users displayed in the pop-up are the MySQL users. The php/sql code is the following : mysql_select_db("mydb", $link) or die(mysql_error()); $query = "INSERT INTO members (username,password,date_of_birth,e_mail,country) VALUES ('". $_POST['username']."','". $_POST['password']."','". $_POST['dateofbirth']."','". $_POST['email']."','". $_POST['country']."')"; $result = mysql_query($query, $link) or die($query . " - " . mysql_error()); Thank you for any help ! -- View this message in context: http://www.nabble.com/PhP---MySQL-problem-tf4349742.html#a12393567 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
Hi there, good morning, as posted yesterday (I guess it kind of got overlooked by the nmber of posts here), I was such a dirk that I put a hidden action in my form that redirected the test page to another (currently running) form which didn't have the changes in it. So my test page showed me data of a live page... dumb me, I know. But after hours and hours of coding, I bet this even happens to the best out there :oP Little piece of code sticking somewhere and you don't even remember that it is there... that reminds me to continue writing the handbook to this website *g* Have a great coding-day :o)) Chris - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, May 22, 2007 2:42 AM Subject: Re: [PHP] PHP & MySQL Problem On Mon, May 21, 2007 2:26 am, Christian Haensel wrote: Good morning friends, I have a script that collects data from a form and puts together a mysql query to search a database. Now, everything worked fine until I added a few new form fields... now the $_POST['var'] don't reach the script... I have about 20 to 25 form fields which are all taken into the query... Now my question: is there a limit in the fields that I can use in the query string to query the database? Somehow the script doesn't even output the value of the POST data anymore... been using this stuff for years now, and i'm feeling really silly at the moment. I'd appreciate any help. POST data *does* have a limit, possibly, based on your selection of browser/server software... It's a ridiculously high limit however, so it seems more likely that you just added a typo to your code. Show us code to get an answer. And estimate for us the size of the POST data as well. Without those bits of info, our answers will be: Maybe. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
On Mon, May 21, 2007 2:26 am, Christian Haensel wrote: > Good morning friends, > > I have a script that collects data from a form and puts together a > mysql > query to search a database. > Now, everything worked fine until I added a few new form fields... now > the > $_POST['var'] don't reach the script... > > I have about 20 to 25 form fields which are all taken into the > query... > > Now my question: is there a limit in the fields that I can use in the > query > string to query the database? Somehow the script doesn't even output > the > value of the POST data anymore... been using this stuff for years now, > and > i'm feeling really silly at the moment. > > I'd appreciate any help. POST data *does* have a limit, possibly, based on your selection of browser/server software... It's a ridiculously high limit however, so it seems more likely that you just added a typo to your code. Show us code to get an answer. And estimate for us the size of the POST data as well. Without those bits of info, our answers will be: Maybe. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
Guys nevermind... stupid moron that I am I put a hidden action in the form whích I totally (!!) forgot... All my code is fine so far, and all is working perfectly... now that bloddy thing cost me 3 DAYS of work... sometimes I wonder if I should rather sell shoes than calling myself a webdeveloper and work at that job all day long... geez! Anyhow, thanks for your help guys... time for Aspirin over here... laterz! Chris - Original Message - From: "Zoltán Németh" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Monday, May 21, 2007 10:16 AM Subject: Re: [PHP] PHP & MySQL Problem 2007. 05. 21, hétfő keltezéssel 10.04-kor Christian Haensel ezt írta: I thought so, too. But the part where it receives the data is this: $s_marke = $_POST['marke']; $s_modell = $_POST['modell']; $s_preis_von = $_POST['preis_von']; $s_preis_bis = $_POST['preis_bis']; $s_mileage_von = $_POST['mileage_from']; $s_mileage_bis = $_POST['mileage_to']; $s_ez_von = $_POST['ez_from']; $s_ez_bis = $_POST['ez_bis']; $s_search_text = $_POST['search_text']; $s_cat = $_POST['cat']; $kw_von = $_POST['kw_von']; $kw_bis = $_POST['kw_bis']; (part of it) And this is the relevant part of the *** 44/60 55/75 66/90 81/110 92/125 110/150 147/200 184/250 220/300 257/350 The funny thing is that all vars are being received except for the last two: $kw_von = $_POST['kw_von']; $kw_bis = $_POST['kw_bis']; and if you do a var_dump($_POST) what do you get? are these values not showing up at all? if so, then you should check whether they are within the and tags... I made that mistake once... greets Zoltán Németh I am s stuck here, it ain't even funny anymore *g* And my boss is, of course, waiting for a result. Howcome people don't get that programming sometimes really IS leaning back and closing your eyes *gr* :oP Thanks for trying to help me :o) Chris ----- Original Message - From: "Zoltán Németh" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Monday, May 21, 2007 9:58 AM Subject: Re: [PHP] PHP & MySQL Problem > 2007. 05. 21, hétfő keltezéssel 09.43-kor Christian Haensel ezt írta: >> Right, here we go... this page has about 1000 lines of code, so here >> the >> relevant stuff. >> >> $s_query = "SELECT * FROM database WHERE >> kategorie LIKE '$s_cat' AND >> marke LIKE '$s_marke' AND >> leistung_kw >= '$kw_von' AND leistung_kw <= '$kw_bis' AND >> preis >= '$s_preis_von' AND >> preis <= '$s_preis_bis'".$checkboxes.$sort_str; >> >> I get the $checkboxes from the POST checkboxes, which looks like this >> (an >> example): >> >> $kraftstoffart = $_POST['fueltype']; >> if($kraftstoffart == "3") { >> $checkboxes .= ""; >> }elseif($kraftstoffart == "2") { >> $checkboxes .= " AND kraftstoffart = '2'"; >> }elseif($kraftstoffart == "1") { >> $checkboxes .= " AND kraftstoffart = '1'"; >> } >> >> and the $sort_str comes in like >> >> $sort_by = $_POST['sort_by']; >> $desc_asc = $_POST['desc_asc']; >> $sort_str = " ORDER BY ".$sort_by." ".$desc_asc; >> >> >> The query then just goes like >> $do_q = mysql_query($s_query) or die(mysql_error()); >> >> and that's it... no errors shown, just the regular output which I had >> before I put the new fields in there. So no changes to what I've had >> before... but there should be changes *g* > > actually there seems to be no problem with your query (besides that you > should check posted values first in order to avoid SQL injection) > > you said in your first letter that "$_POST['var'] don't reach the > script" - I would guess the relevant part is not the query but rather > the form itself... > > greets > Zoltán Németh > >> >> I hope anybody can find some sense in what I'm writing here... hardly >> makes >> sense to me :oP >> >> Cheers! >> >> >> >> >> >> >> >> - Original Message - >> From: "Zoltán Németh" <[EMAIL PROTECTED]> >> To: "Christian Haensel" <[EMAIL PROTECTED]> >> Cc: >> Sent: Monday, May 21, 2007 9:36 AM >> Subject: Re: [PHP] PHP & MySQL Problem >> >> >> > 2007. 05. 2
Re: [PHP] PHP & MySQL Problem
2007. 05. 21, hétfő keltezéssel 10.04-kor Christian Haensel ezt írta: > I thought so, too. But the part where it receives the data is this: > > $s_marke = $_POST['marke']; > $s_modell = $_POST['modell']; > $s_preis_von = $_POST['preis_von']; > $s_preis_bis = $_POST['preis_bis']; > $s_mileage_von = $_POST['mileage_from']; > $s_mileage_bis = $_POST['mileage_to']; > $s_ez_von = $_POST['ez_from']; > $s_ez_bis = $_POST['ez_bis']; > $s_search_text = $_POST['search_text']; > $s_cat = $_POST['cat']; > $kw_von = $_POST['kw_von']; > $kw_bis = $_POST['kw_bis']; > > (part of it) > > And this is the relevant part of the > > > *** > 44/60 > > 55/75 > 66/90 > 81/110 > 92/125 > 110/150 > 147/200 > 184/250 > 220/300 > 257/350 > > > The funny thing is that all vars are being received except for the last two: > $kw_von = $_POST['kw_von']; > $kw_bis = $_POST['kw_bis']; and if you do a var_dump($_POST) what do you get? are these values not showing up at all? if so, then you should check whether they are within the and tags... I made that mistake once... greets Zoltán Németh > > I am s stuck here, it ain't even funny anymore *g* And my boss is, of > course, waiting for a result. Howcome people don't get that programming > sometimes really IS leaning back and closing your eyes *gr* :oP > > Thanks for trying to help me :o) > > Chris > > - Original Message - > From: "Zoltán Németh" <[EMAIL PROTECTED]> > To: "Christian Haensel" <[EMAIL PROTECTED]> > Cc: > Sent: Monday, May 21, 2007 9:58 AM > Subject: Re: [PHP] PHP & MySQL Problem > > > > 2007. 05. 21, hétfő keltezéssel 09.43-kor Christian Haensel ezt írta: > >> Right, here we go... this page has about 1000 lines of code, so here the > >> relevant stuff. > >> > >> $s_query = "SELECT * FROM database WHERE > >> kategorie LIKE '$s_cat' AND > >> marke LIKE '$s_marke' AND > >> leistung_kw >= '$kw_von' AND leistung_kw <= '$kw_bis' AND > >> preis >= '$s_preis_von' AND > >> preis <= '$s_preis_bis'".$checkboxes.$sort_str; > >> > >> I get the $checkboxes from the POST checkboxes, which looks like this (an > >> example): > >> > >> $kraftstoffart = $_POST['fueltype']; > >> if($kraftstoffart == "3") { > >> $checkboxes .= ""; > >> }elseif($kraftstoffart == "2") { > >> $checkboxes .= " AND kraftstoffart = '2'"; > >> }elseif($kraftstoffart == "1") { > >> $checkboxes .= " AND kraftstoffart = '1'"; > >> } > >> > >> and the $sort_str comes in like > >> > >> $sort_by = $_POST['sort_by']; > >> $desc_asc = $_POST['desc_asc']; > >> $sort_str = " ORDER BY ".$sort_by." ".$desc_asc; > >> > >> > >> The query then just goes like > >> $do_q = mysql_query($s_query) or die(mysql_error()); > >> > >> and that's it... no errors shown, just the regular output which I had > >> before I put the new fields in there. So no changes to what I've had > >> before... but there should be changes *g* > > > > actually there seems to be no problem with your query (besides that you > > should check posted values first in order to avoid SQL injection) > > > > you said in your first letter that "$_POST['var'] don't reach the > > script" - I would guess the relevant part is not the query but rather > > the form itself... > > > > greets > > Zoltán Németh > > > >> > >> I hope anybody can find some sense in what I'm writing here... hardly > >> makes > >> sense to me :oP > >> > >> Cheers! > >> > >> > >> > >> > >> > >> > >> > >> - Original Message - > >> From: "Zoltán Németh" <[EMAIL PROTECTED]> > >> To: "Christian Haensel" <[EMAIL PROTECTED]> > >> Cc: > >> Sent: Monday, May 21, 2007 9:36 AM > >> Subject: Re: [PHP] PHP & MySQL Problem > >> > >> > >> > 2007. 05. 21, hétfő keltezéssel 09.26-kor Christian Haensel ezt írta: > >> >> Good morning friends, > >> >> > >> >> I have a script that collects data from a form and puts together a > >> >> mysql > >> >> query to search a database. > >> >> Now, everything worked fine until I added a few new form fields... now > >> >> the > >> >> $_POST['var'] don't reach the script... > >> >> > >> >> I have about 20 to 25 form fields which are all taken into the > >> >> query... > >> >> > >> >> Now my question: is there a limit in the fields that I can use in the > >> >> query > >> >> string to query the database? Somehow the script doesn't even output > >> >> the > >> >> value of the POST data anymore... been using this stuff for years now, > >> >> and > >> >> i'm feeling really silly at the moment. > >> > > >> > AFAIK there is no limit in the number of fields in a query... > >> > post some code please, otherwise I don't think anyone will be able to > >> > help you > >> > > >> > greets > >> > Zoltán Németh > >> > > >> >> > >> >> I'd appreciate any help. > >> >> > >> >> Cheers! > >> >> Chris > >> >> > >> > > >> > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
I thought so, too. But the part where it receives the data is this: $s_marke = $_POST['marke']; $s_modell = $_POST['modell']; $s_preis_von = $_POST['preis_von']; $s_preis_bis = $_POST['preis_bis']; $s_mileage_von = $_POST['mileage_from']; $s_mileage_bis = $_POST['mileage_to']; $s_ez_von = $_POST['ez_from']; $s_ez_bis = $_POST['ez_bis']; $s_search_text = $_POST['search_text']; $s_cat = $_POST['cat']; $kw_von = $_POST['kw_von']; $kw_bis = $_POST['kw_bis']; (part of it) And this is the relevant part of the *** 44/60 55/75 66/90 81/110 92/125 110/150 147/200 184/250 220/300 257/350 The funny thing is that all vars are being received except for the last two: $kw_von = $_POST['kw_von']; $kw_bis = $_POST['kw_bis']; I am s stuck here, it ain't even funny anymore *g* And my boss is, of course, waiting for a result. Howcome people don't get that programming sometimes really IS leaning back and closing your eyes *gr* :oP Thanks for trying to help me :o) Chris - Original Message ----- From: "Zoltán Németh" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Monday, May 21, 2007 9:58 AM Subject: Re: [PHP] PHP & MySQL Problem 2007. 05. 21, hétfő keltezéssel 09.43-kor Christian Haensel ezt írta: Right, here we go... this page has about 1000 lines of code, so here the relevant stuff. $s_query = "SELECT * FROM database WHERE kategorie LIKE '$s_cat' AND marke LIKE '$s_marke' AND leistung_kw >= '$kw_von' AND leistung_kw <= '$kw_bis' AND preis >= '$s_preis_von' AND preis <= '$s_preis_bis'".$checkboxes.$sort_str; I get the $checkboxes from the POST checkboxes, which looks like this (an example): $kraftstoffart = $_POST['fueltype']; if($kraftstoffart == "3") { $checkboxes .= ""; }elseif($kraftstoffart == "2") { $checkboxes .= " AND kraftstoffart = '2'"; }elseif($kraftstoffart == "1") { $checkboxes .= " AND kraftstoffart = '1'"; } and the $sort_str comes in like $sort_by = $_POST['sort_by']; $desc_asc = $_POST['desc_asc']; $sort_str = " ORDER BY ".$sort_by." ".$desc_asc; The query then just goes like $do_q = mysql_query($s_query) or die(mysql_error()); and that's it... no errors shown, just the regular output which I had before I put the new fields in there. So no changes to what I've had before... but there should be changes *g* actually there seems to be no problem with your query (besides that you should check posted values first in order to avoid SQL injection) you said in your first letter that "$_POST['var'] don't reach the script" - I would guess the relevant part is not the query but rather the form itself... greets Zoltán Németh I hope anybody can find some sense in what I'm writing here... hardly makes sense to me :oP Cheers! - Original Message - From: "Zoltán Németh" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Monday, May 21, 2007 9:36 AM Subject: Re: [PHP] PHP & MySQL Problem > 2007. 05. 21, hétfő keltezéssel 09.26-kor Christian Haensel ezt írta: >> Good morning friends, >> >> I have a script that collects data from a form and puts together a >> mysql >> query to search a database. >> Now, everything worked fine until I added a few new form fields... now >> the >> $_POST['var'] don't reach the script... >> >> I have about 20 to 25 form fields which are all taken into the >> query... >> >> Now my question: is there a limit in the fields that I can use in the >> query >> string to query the database? Somehow the script doesn't even output >> the >> value of the POST data anymore... been using this stuff for years now, >> and >> i'm feeling really silly at the moment. > > AFAIK there is no limit in the number of fields in a query... > post some code please, otherwise I don't think anyone will be able to > help you > > greets > Zoltán Németh > >> >> I'd appreciate any help. >> >> Cheers! >> Chris >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
2007. 05. 21, hétfő keltezéssel 09.43-kor Christian Haensel ezt írta: > Right, here we go... this page has about 1000 lines of code, so here the > relevant stuff. > > $s_query = "SELECT * FROM database WHERE > kategorie LIKE '$s_cat' AND > marke LIKE '$s_marke' AND > leistung_kw >= '$kw_von' AND leistung_kw <= '$kw_bis' AND > preis >= '$s_preis_von' AND > preis <= '$s_preis_bis'".$checkboxes.$sort_str; > > I get the $checkboxes from the POST checkboxes, which looks like this (an > example): > > $kraftstoffart = $_POST['fueltype']; > if($kraftstoffart == "3") { > $checkboxes .= ""; > }elseif($kraftstoffart == "2") { > $checkboxes .= " AND kraftstoffart = '2'"; > }elseif($kraftstoffart == "1") { > $checkboxes .= " AND kraftstoffart = '1'"; > } > > and the $sort_str comes in like > > $sort_by = $_POST['sort_by']; > $desc_asc = $_POST['desc_asc']; > $sort_str = " ORDER BY ".$sort_by." ".$desc_asc; > > > The query then just goes like > $do_q = mysql_query($s_query) or die(mysql_error()); > > and that's it... no errors shown, just the regular output which I had > before I put the new fields in there. So no changes to what I've had > before... but there should be changes *g* actually there seems to be no problem with your query (besides that you should check posted values first in order to avoid SQL injection) you said in your first letter that "$_POST['var'] don't reach the script" - I would guess the relevant part is not the query but rather the form itself... greets Zoltán Németh > > I hope anybody can find some sense in what I'm writing here... hardly makes > sense to me :oP > > Cheers! > > > > > > > > - Original Message - > From: "Zoltán Németh" <[EMAIL PROTECTED]> > To: "Christian Haensel" <[EMAIL PROTECTED]> > Cc: > Sent: Monday, May 21, 2007 9:36 AM > Subject: Re: [PHP] PHP & MySQL Problem > > > > 2007. 05. 21, hétfő keltezéssel 09.26-kor Christian Haensel ezt írta: > >> Good morning friends, > >> > >> I have a script that collects data from a form and puts together a mysql > >> query to search a database. > >> Now, everything worked fine until I added a few new form fields... now > >> the > >> $_POST['var'] don't reach the script... > >> > >> I have about 20 to 25 form fields which are all taken into the query... > >> > >> Now my question: is there a limit in the fields that I can use in the > >> query > >> string to query the database? Somehow the script doesn't even output the > >> value of the POST data anymore... been using this stuff for years now, > >> and > >> i'm feeling really silly at the moment. > > > > AFAIK there is no limit in the number of fields in a query... > > post some code please, otherwise I don't think anyone will be able to > > help you > > > > greets > > Zoltán Németh > > > >> > >> I'd appreciate any help. > >> > >> Cheers! > >> Chris > >> > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
Right, here we go... this page has about 1000 lines of code, so here the relevant stuff. $s_query = "SELECT * FROM database WHERE kategorie LIKE '$s_cat' AND marke LIKE '$s_marke' AND leistung_kw >= '$kw_von' AND leistung_kw <= '$kw_bis' AND preis >= '$s_preis_von' AND preis <= '$s_preis_bis'".$checkboxes.$sort_str; I get the $checkboxes from the POST checkboxes, which looks like this (an example): $kraftstoffart = $_POST['fueltype']; if($kraftstoffart == "3") { $checkboxes .= ""; }elseif($kraftstoffart == "2") { $checkboxes .= " AND kraftstoffart = '2'"; }elseif($kraftstoffart == "1") { $checkboxes .= " AND kraftstoffart = '1'"; } and the $sort_str comes in like $sort_by = $_POST['sort_by']; $desc_asc = $_POST['desc_asc']; $sort_str = " ORDER BY ".$sort_by." ".$desc_asc; The query then just goes like $do_q = mysql_query($s_query) or die(mysql_error()); and that's it... no errors shown, just the regular output which I had before I put the new fields in there. So no changes to what I've had before... but there should be changes *g* I hope anybody can find some sense in what I'm writing here... hardly makes sense to me :oP Cheers! - Original Message - From: "Zoltán Németh" <[EMAIL PROTECTED]> To: "Christian Haensel" <[EMAIL PROTECTED]> Cc: Sent: Monday, May 21, 2007 9:36 AM Subject: Re: [PHP] PHP & MySQL Problem 2007. 05. 21, hétfő keltezéssel 09.26-kor Christian Haensel ezt írta: Good morning friends, I have a script that collects data from a form and puts together a mysql query to search a database. Now, everything worked fine until I added a few new form fields... now the $_POST['var'] don't reach the script... I have about 20 to 25 form fields which are all taken into the query... Now my question: is there a limit in the fields that I can use in the query string to query the database? Somehow the script doesn't even output the value of the POST data anymore... been using this stuff for years now, and i'm feeling really silly at the moment. AFAIK there is no limit in the number of fields in a query... post some code please, otherwise I don't think anyone will be able to help you greets Zoltán Németh I'd appreciate any help. Cheers! Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & MySQL Problem
2007. 05. 21, hétfő keltezéssel 09.26-kor Christian Haensel ezt írta: > Good morning friends, > > I have a script that collects data from a form and puts together a mysql > query to search a database. > Now, everything worked fine until I added a few new form fields... now the > $_POST['var'] don't reach the script... > > I have about 20 to 25 form fields which are all taken into the query... > > Now my question: is there a limit in the fields that I can use in the query > string to query the database? Somehow the script doesn't even output the > value of the POST data anymore... been using this stuff for years now, and > i'm feeling really silly at the moment. AFAIK there is no limit in the number of fields in a query... post some code please, otherwise I don't think anyone will be able to help you greets Zoltán Németh > > I'd appreciate any help. > > Cheers! > Chris > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP & MySQL Problem
Good morning friends, I have a script that collects data from a form and puts together a mysql query to search a database. Now, everything worked fine until I added a few new form fields... now the $_POST['var'] don't reach the script... I have about 20 to 25 form fields which are all taken into the query... Now my question: is there a limit in the fields that I can use in the query string to query the database? Somehow the script doesn't even output the value of the POST data anymore... been using this stuff for years now, and i'm feeling really silly at the moment. I'd appreciate any help. Cheers! Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php-mysql problem
$sql = "SELECT count(Email) as numEmails, Email FROM mena_guests WHERE Voted='yes' GROUP BY Email ORDER BY numEmails DESC LIMIT $startingID, $items_numbers_list"; I answered this morning, I don't know why it got deleted -- itoctopus - http://www.itoctopus.com ""Me2resh Lists"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi > i need help regarding a sql query in my php app. > > the query is : > $SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' > LIMIT $startingID,$items_numbers_list"; > > i want to sort this query by the number of the repeated EMail counts. > can anyone help me with that please ? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
if I asked you whether your wife/girlfriend enjoyed having sex with your best friend while you are at work then you may or may not know the answer but it is hopefully clear that this is not the list to ask such a question (but no doubt that there is a list somewhere that caters to that kind of shit) ... conceptually what goes for your other half also goes for SQL. ha ha thats funny, but true and well explained :) - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
cajbecu wrote: clive wrote: Me2resh Lists wrote: the query is : $SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' LIMIT $startingID,$items_numbers_list"; the only php I see it $SQL,$startingID,$items_numbers_list. This is a mysql question. so, you don`t know the answer, right? cajb. Well if I understand the question correctly, then yes I could have an answer. I have solved something similar a while back, unfortunately I don't remember the correct sql and would have too populate a db table and try a few sql commands which is something me2resh should do until he gets the correct results. clive -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
cajbecu wrote: > clive wrote: >> Me2resh Lists wrote: >>> the query is : >>>$SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' >>> LIMIT $startingID,$items_numbers_list"; >> the only php I see it $SQL,$startingID,$items_numbers_list. This is a >> mysql question. >> > > so, you don`t know the answer, right? maybe he does maybe he doesn't - the point is trying to educate people as to the best/correct place to ask questions. questions related purely to SQL should be dealt with else where in cyberspace. if I asked you whether your wife/girlfriend enjoyed having sex with your best friend while you are at work then you may or may not know the answer but it is hopefully clear that this is not the list to ask such a question (but no doubt that there is a list somewhere that caters to that kind of shit) ... conceptually what goes for your other half also goes for SQL. > > cajb. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
clive wrote: > Me2resh Lists wrote: >> the query is : >>$SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' >> LIMIT $startingID,$items_numbers_list"; > > the only php I see it $SQL,$startingID,$items_numbers_list. This is a > mysql question. > so, you don`t know the answer, right? cajb. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php-mysql problem
> i need help regarding a sql query in my php app. > > the query is : > $SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE > Voted = 'yes' > LIMIT $startingID,$items_numbers_list"; > > i want to sort this query by the number of the repeated EMail counts. > can anyone help me with that please ? A) Is this a PHP question? If so, please post the PHP code you are having trouble with. B) While you could dump the results of your query into an array, and use sort() or the other array sorting methods to sort it any way you wanted to (thus making this a PHP question), it would certainly be more efficient to have MySQL return a properly sorted result set to begin with. C) It appears that by your use of DISTINCT(), you will not have repeating EMail values in your result set, thus you could not sort it by repeating emails. D) You will find many more relevant answers and many more willing participants if you were to post your question to a MySQL oriented list. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
Me2resh Lists wrote: the query is : $SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' LIMIT $startingID,$items_numbers_list"; the only php I see it $SQL,$startingID,$items_numbers_list. This is a mysql question. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php-mysql problem
$sql = "SELECT count(Email) as numEmails, Email FROM mena_guests WHERE Voted='yes' GROUP BY Email ORDER BY numEmails DESC LIMIT $startingID, $items_numbers_list"; -- itoctopus - http://www.itoctopus.com ""Me2resh Lists"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > hi > i need help regarding a sql query in my php app. > > the query is : > $SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' > LIMIT $startingID,$items_numbers_list"; > > i want to sort this query by the number of the repeated EMail counts. > can anyone help me with that please ? > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
Me2resh Lists wrote: > hi > i need help regarding a sql query in my php app. > > the query is : >$SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' > LIMIT $startingID,$items_numbers_list"; > > i want to sort this query by the number of the repeated EMail counts. > can anyone help me with that please ? somebody on a mysql mailing list per chance? you are trying to solve a problem that is purely related to SQL query building, this has nothing to do with php. I would suggest you check out the mysql manual and read up on 'GROUP BY', 'COUNT()' and 'ORDER BY' - from your question I am guessing that these three hold the answer to your problem between them > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php-mysql problem
hi i need help regarding a sql query in my php app. the query is : $SQL = "SELECT DISTINCT(EMail) FROM mena_guests WHERE Voted = 'yes' LIMIT $startingID,$items_numbers_list"; i want to sort this query by the number of the repeated EMail counts. can anyone help me with that please ?
Re: [PHP] Re: php mysql problem
On 5/3/06, Richard Lynch <[EMAIL PROTECTED]> wrote: On Tue, May 2, 2006 7:22 am, chris smith wrote: > On 5/2/06, Ross <[EMAIL PROTECTED]> wrote: >> This is my database now...I will use the item_id for the order but >> what if I >> want to change item_id 3 to item id 1? How can I push all the items >> down one >> place? How can I delete any gaps when items are deleted. > > Why do you want to do that? There's no benefit in doing this.. > actually it becomes a pain. > > You'd need to update not only this table but any field in other tables > that references this one as well (and if you miss one, you have a > completely useless database). No, we've got past that bit. I posted that answer yesterday... By the time I got back to the thread everyone had worked out that he wanted to use it for ordering results ;) While you are at it, "id" is an awfully generic name for a field, really. I personally prefer: create table foo (foo_id int(11) auto_increment, ...); But, hey, a lot of folks go with just "id" on everything, and seem okay with that. [shrug] Very true - would get rather confusing in link tables: create table news_cat (id int, id int); heh. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php mysql problem
On Tue, May 2, 2006 7:22 am, chris smith wrote: > On 5/2/06, Ross <[EMAIL PROTECTED]> wrote: >> This is my database now...I will use the item_id for the order but >> what if I >> want to change item_id 3 to item id 1? How can I push all the items >> down one >> place? How can I delete any gaps when items are deleted. > > Why do you want to do that? There's no benefit in doing this.. > actually it becomes a pain. > > You'd need to update not only this table but any field in other tables > that references this one as well (and if you miss one, you have a > completely useless database). No, we've got past that bit. Now he just wants user-definable ordering in sequence from 1 to N, using item_id as the user-modifiable field, and "id" as the auto_increment field. item_id is a HORRIBLE name for such a field, mind you... Call it "rank" or something, okay Ross? While you are at it, "id" is an awfully generic name for a field, really. I personally prefer: create table foo (foo_id int(11) auto_increment, ...); But, hey, a lot of folks go with just "id" on everything, and seem okay with that. [shrug] -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php mysql problem
On Tue, May 2, 2006 7:05 am, Ross wrote: > This is my database now...I will use the item_id for the order but > what if I > want to change item_id 3 to item id 1? How can I push all the items > down one > place? How can I delete any gaps when items are deleted. Change item_id 3 to 1. ... select id from board_papers where item_id = 3 ... $id3 = mysql_result($result); ... select id from board_papers where item_id = 1 ... $id1 = mysql_result($result); ... update board_papers set item_id = 1 where id = $id3 ... update board_papers set item_id = 3 where id = $id1 Delete an item: $item_id = 42; ... delete from board_papers where item_id = 42 ... update board_papers set item_id = item_id - 1 where item_id > 42 It's up to you to actually add all the function calls and quotes and error-checking and make it work for variables instead of constants. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mysql problem
On Tue, May 2, 2006 5:00 am, Ross wrote: > CREATE TABLE `mytable` ( > `id` int(4) NOT NULL auto_increment, > `fileName` varchar(50) NOT NULL default '', > PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; > > > when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. > 1, 3, > 7. I need to know > > (a) when items are removed how can I sort the database to all the gaps > are > take out 1, 3, 7 becomes 1,2,3 You do *NOT* want to do this on an auto_increment field in a relational database. It's just a Bad Idea in so many ways... For starters, you're going to need that 'id' field in a bunch of other tables to relate the two tables -- That's kinda why they call it a RELATIONAL database. So if you re-number this table, you have to go through all the other tables related to this table and update them as well. You're looking at a cascading nightmare of updates. > (b) allow the ids to be changed so the items can change position in > the > list. If I change id 3 to id 1 then everything else shifts down. > > If anyone has seen the amazon dvd rental list where you can swap dvd > to the > top of the list and delete this is what I am trying to achive with > php/mysql. THAT is another kettle of fish entirely. You pretty much just need to manage the numbering on a different column "by hand" create table mytable(id int(11) auto_increment, rank int(4)); Queries you will find useful: //The rank for the new item added to end of list: select max(rank) + 1 from mytable; //Queries to move to top of list: $id = /* get ID of row here */ $rank = /* get current $rank of that row here */ update mytable set rank = rank + 1 where rank < $rank update mytable set rank = 1 where id = $id It's easy to mess up and get everything "off by one" but this is not rocket science to figure out and debug. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mysql problem
Ross wrote: This is my database now...I will use the item_id for the order but what if I want to change item_id 3 to item id 1? How can I push all the items down one place? How can I delete any gaps when items are deleted. CREATE TABLE `board_papers` ( `id` int(4) NOT NULL auto_increment, `doc_date` varchar(10) NOT NULL default '-00-00', `article_type` enum('agenda','minutes','paper') NOT NULL default 'agenda', `fileName` varchar(50) NOT NULL default '', `fileSize` int(4) NOT NULL default '0', `fileType` varchar(50) NOT NULL default '', `content` blob NOT NULL, `item_id` int(10) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; -- snip -- Hi Ross, You can reuse item_id after they have been deleted. So when you delete item_id = 1, then next time you perform an insert, lookup the lowest free item_id number and give it as the item_id. That's one small solution. If you actually want to rank your records by more than just the item_id, then define a field for each kind of rank you want, or better, add it as a separate table, like: board_papers -< rank * id * board_papers_fk <-- id from board_papers * rank_type (example: readability, technicality...) * rank_no (rank within the rank type) Then you can order the board_papers after rank as you like! Just an idea :) Enjoy, John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mysql problem
Ross wrote: This is my database now...I will use the item_id for the order but what if I want to change item_id 3 to item id 1? How can I push all the items down one place? How can I delete any gaps when items are deleted. CREATE TABLE `board_papers` ( `id` int(4) NOT NULL auto_increment, `doc_date` varchar(10) NOT NULL default '-00-00', `article_type` enum('agenda','minutes','paper') NOT NULL default 'agenda', `fileName` varchar(50) NOT NULL default '', `fileSize` int(4) NOT NULL default '0', `fileType` varchar(50) NOT NULL default '', `content` blob NOT NULL, `item_id` int(10) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; -- snip -- Hi Ross, You can reuse item_id after they have been deleted. So when you delete item_id = 1, then next time you perform an insert, lookup the lowest free item_id number and give it as the item_id. That's one small solution. If you actually want to rank your records by more than just the item_id, then define a field for each kind of rank you want, or better, add it as a separate table, like: board_papers -< rank * id * board_papers_fk <-- id from board_papers * rank_type (example: readability, technicality...) * rank_no (rank within the rank type) Then you can order the board_papers after rank as you like! Just an idea :) Enjoy, John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mysql problem
Depending on your needs, here is another tack to think about (I know, everyone else will be gasping and running for air...) A few years ago I had to make a shopping cart. I had an archaic system that would not share information with my web/db server, so I had to write a query to dump the products, quantity, price levels, etc out of it to a CSV file. I then used perl to get the file, reformat it into SQL files, then run an empty of the table and recreate with all the data that I just got off the server. To get past the naming conventions and such and NOT lose any linked tables, I did my joins and such off the product ID. The Caveat to this was that the products (even those we no longer sold) stayed in the system for about 6 months, and by the time we were ready to purge those, the orders were saved and could not be deleted (PDF and as saved data) so that was never a problem. That solved the product counts for me (since the bosses were a bit anal about having accurate product counts and such) and kept that table tidy. Customers was not so tidy, nor wore the other tables. But you can only work with what you can do. In short, unless you have a very good reason and safety checks to keep your data from getting lost from other tables, you might need to rethink why you want that. If you want to chew the fat and talk design, shoot me a message off-list and I'll be glad to help. Wolf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php mysql problem
At 11:00 AM +0100 5/2/06, Ross wrote: Just say I have a db CREATE TABLE `mytable` ( `id` int(4) NOT NULL auto_increment, `fileName` varchar(50) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, 3, 7. I need to know (a) when items are removed how can I sort the database to all the gaps are take out 1, 3, 7 becomes 1,2,3 Ross: I am sure that the advice of everyone here and on any mysql list will be NOT to do what you are asking. You're looking at the ID as if the order of that field means something, it shouldn't. However, to provide you with what you asked for, please review: /* Renumber the Existing Sequence alter table mytable drop id, add id int unsigned not null auto_increment, auto_increment = 1; Keep in mind that by doing this, your dB should remain flat -- you cannot successfully renumber a relational dB without also considering all the dependant tables, which is not trivial. HTH's more than it hurts. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php mysql problem
Exactly - I don't think you really understand how a relational database works. The ids are retained as they may relate to records in another table. Internal sorting order is of no relevance at the application level. I think you need to rethink your design a little. On 02/05/06, T.Lensselink <[EMAIL PROTECTED]> wrote: > This is my database now...I will use the item_id for the order but what if > I > want to change item_id 3 to item id 1? How can I push all the items down > one > place? How can I delete any gaps when items are deleted. > > > CREATE TABLE `board_papers` ( > `id` int(4) NOT NULL auto_increment, > `doc_date` varchar(10) NOT NULL default '-00-00', > `article_type` enum('agenda','minutes','paper') NOT NULL default > 'agenda', > `fileName` varchar(50) NOT NULL default '', > `fileSize` int(4) NOT NULL default '0', > `fileType` varchar(50) NOT NULL default '', > `content` blob NOT NULL, > `item_id` int(10) default NULL, > PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; > > > > > > ""Ross"" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> Just say I have a db >> >> CREATE TABLE `mytable` ( >> `id` int(4) NOT NULL auto_increment, >> `fileName` varchar(50) NOT NULL default '', >> PRIMARY KEY (`id`) >> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; >> >> >> when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, >> 3, 7. I need to know >> >> (a) when items are removed how can I sort the database to all the gaps >> are >> take out 1, 3, 7 becomes 1,2,3 >> >> (b) allow the ids to be changed so the items can change position in the >> list. If I change id 3 to id 1 then everything else shifts down. >> >> If anyone has seen the amazon dvd rental list where you can swap dvd to >> the top of the list and delete this is what I am trying to achive with >> php/mysql. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Really can't imagine why you wanna do something like this. What's the use in reordering a database. It's just a database. you can sort it in any way you like.. gaps or not.. Sounds to me the sorting is only done on screen. This is pretty easy done with PHP not in the database itself. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
Re: [PHP] Re: php mysql problem
> This is my database now...I will use the item_id for the order but what if > I > want to change item_id 3 to item id 1? How can I push all the items down > one > place? How can I delete any gaps when items are deleted. > > > CREATE TABLE `board_papers` ( > `id` int(4) NOT NULL auto_increment, > `doc_date` varchar(10) NOT NULL default '-00-00', > `article_type` enum('agenda','minutes','paper') NOT NULL default > 'agenda', > `fileName` varchar(50) NOT NULL default '', > `fileSize` int(4) NOT NULL default '0', > `fileType` varchar(50) NOT NULL default '', > `content` blob NOT NULL, > `item_id` int(10) default NULL, > PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; > > > > > > ""Ross"" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> Just say I have a db >> >> CREATE TABLE `mytable` ( >> `id` int(4) NOT NULL auto_increment, >> `fileName` varchar(50) NOT NULL default '', >> PRIMARY KEY (`id`) >> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; >> >> >> when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, >> 3, 7. I need to know >> >> (a) when items are removed how can I sort the database to all the gaps >> are >> take out 1, 3, 7 becomes 1,2,3 >> >> (b) allow the ids to be changed so the items can change position in the >> list. If I change id 3 to id 1 then everything else shifts down. >> >> If anyone has seen the amazon dvd rental list where you can swap dvd to >> the top of the list and delete this is what I am trying to achive with >> php/mysql. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Really can't imagine why you wanna do something like this. What's the use in reordering a database. It's just a database. you can sort it in any way you like.. gaps or not.. Sounds to me the sorting is only done on screen. This is pretty easy done with PHP not in the database itself. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php mysql problem
On 5/2/06, Ross <[EMAIL PROTECTED]> wrote: This is my database now...I will use the item_id for the order but what if I want to change item_id 3 to item id 1? How can I push all the items down one place? How can I delete any gaps when items are deleted. Why do you want to do that? There's no benefit in doing this.. actually it becomes a pain. You'd need to update not only this table but any field in other tables that references this one as well (and if you miss one, you have a completely useless database). -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php mysql problem
This is my database now...I will use the item_id for the order but what if I want to change item_id 3 to item id 1? How can I push all the items down one place? How can I delete any gaps when items are deleted. CREATE TABLE `board_papers` ( `id` int(4) NOT NULL auto_increment, `doc_date` varchar(10) NOT NULL default '-00-00', `article_type` enum('agenda','minutes','paper') NOT NULL default 'agenda', `fileName` varchar(50) NOT NULL default '', `fileSize` int(4) NOT NULL default '0', `fileType` varchar(50) NOT NULL default '', `content` blob NOT NULL, `item_id` int(10) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ; ""Ross"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Just say I have a db > > CREATE TABLE `mytable` ( > `id` int(4) NOT NULL auto_increment, > `fileName` varchar(50) NOT NULL default '', > PRIMARY KEY (`id`) > ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; > > > when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, > 3, 7. I need to know > > (a) when items are removed how can I sort the database to all the gaps are > take out 1, 3, 7 becomes 1,2,3 > > (b) allow the ids to be changed so the items can change position in the > list. If I change id 3 to id 1 then everything else shifts down. > > If anyone has seen the amazon dvd rental list where you can swap dvd to > the top of the list and delete this is what I am trying to achive with > php/mysql. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP] php mysql problem
- Original Message - From: "Ross" <[EMAIL PROTECTED]> To: Sent: Tuesday, May 02, 2006 12:00 PM Subject: [PHP] php mysql problem Just say I have a db CREATE TABLE `mytable` ( `id` int(4) NOT NULL auto_increment, `fileName` varchar(50) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, 3, 7. I need to know (a) when items are removed how can I sort the database to all the gaps are take out 1, 3, 7 becomes 1,2,3 (b) allow the ids to be changed so the items can change position in the list. If I change id 3 to id 1 then everything else shifts down. If anyone has seen the amazon dvd rental list where you can swap dvd to the top of the list and delete this is what I am trying to achive with php/mysql. You are mixing up concepts here. An ID is that, an identifier, and it goes with the record from its creation to its deletion. That's what an ID is for (which in most Anglo legal systems is something people is not used to, an anthropological curiosity if you wish). What you are looking for is an Order field (which, of course, you can name as you wish, since order is a reserved SQL word, I just give the concept of it), which is also numerical and that, if you put in your select like Select * from mytalbe order by `order`, id will be used to order records and, if missing, will default to id. Satyam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php mysql problem
Ross schrieb: Just say I have a db CREATE TABLE `mytable` ( `id` int(4) NOT NULL auto_increment, `fileName` varchar(50) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, 3, 7. I need to know (a) when items are removed how can I sort the database to all the gaps are take out 1, 3, 7 becomes 1,2,3 Why do you auto_increment them then? Normally it's very wrong to set back autoincremented values because you don't have any reference anymore. So if ID X is causing an error it could be Article X or Article Y or article Z. You don't know because the database is shifting it around. Add a second field called "sort" or something similiar and let it sort on that. Or give it Article Numbers or whatever. (b) allow the ids to be changed so the items can change position in the list. If I change id 3 to id 1 then everything else shifts down. update id = id +1 WHERE id > X Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php mysql problem
Just say I have a db CREATE TABLE `mytable` ( `id` int(4) NOT NULL auto_increment, `fileName` varchar(50) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; when I add items they go id 1,2,3 etc. Whn I delete them gaps appear. 1, 3, 7. I need to know (a) when items are removed how can I sort the database to all the gaps are take out 1, 3, 7 becomes 1,2,3 (b) allow the ids to be changed so the items can change position in the list. If I change id 3 to id 1 then everything else shifts down. If anyone has seen the amazon dvd rental list where you can swap dvd to the top of the list and delete this is what I am trying to achive with php/mysql. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php - mysql problem
thanks a lot for your posting, [cut] Posted by Fred Mitchell on December 11 2004 2:47pm [Delete] [Edit] Let's say you are doing a LEFT JOIN with a table that shares a column name in common with another table, and that you are selecting for instances where the join is missing, that is IS NULL. Normally, the common column name is "wiped out" by the null record, but here is a workaround for it: You simply alias that common column name in the select. For instance, CREATE TABLE t1 (INT id NOT NULL, ); CREATE TABLE t2 (INT id NOT NULL, ); ... SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id WHERE t2.id IS NULL; would result in the column 'id' being null on each selected row. Instead, you can do: SELECT *, t1.id AS id FROM t1 LEFT JOIN t2 ON t1.id = t2.id WHERE t2.id IS NULL; And now the 'id' column will be preserved since the alias is evaluated *after* the LEFT JOIN. [/cut] pay attention to: -> *, t1.id <- cheers, cajbecu Jay Blanchard wrote: > [snip] > $sql = "SELECT * FROM `table1` LEFT JOIN `table2` USING `id` WHERE ... > GROUP BY `table1`.`id`"; > > mysql_query($sql); > > the problem is, that, when in table2 is not matching data using that id, > i lose that id from output array. but i don`t want to.. is there any > posibility to keep that id? > [/snip] > > More of a mysql question but do a left outer join with no group by > statement. > > SELECT table2.* > FROM table1 LEFT OUTER JOIN table2 > ON(table1.id = table2.id) > WHERE table1.id IS NULL > > > Returns all of table2 id's where there is no id in table1 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php - mysql problem
[snip] > SELECT table1., *table2.* > FROM table1 LEFT OUTER JOIN table2 > ON(table1.id = table2.id) [/snip] Oops, typo. SELECT table1.*, table2.* FROM table1 LEFT OUTER JOIN table2 ON(table1.id = table2.id) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php - mysql problem
[snip] table1 id name value table2 id x y i want to id name value x y but there is no id from table 2 that is in table2.id and i want the resource to bu something like this: id(from table 1) name value (empty) (empty) > SELECT table2.* > FROM table1 LEFT OUTER JOIN table2 > ON(table1.id = table2.id) > WHERE table1.id IS NULL [/snip] > SELECT table1., *table2.* > FROM table1 LEFT OUTER JOIN table2 > ON(table1.id = table2.id) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php - mysql problem
thanks for your posting, but I have: table1 id name value table2 id x y i want to id name value x y but there is no id from table 2 that is in table2.id and i want the resource to bu something like this: id(from table 1) name value (empty) (empty) Jay Blanchard wrote: > [snip] > $sql = "SELECT * FROM `table1` LEFT JOIN `table2` USING `id` WHERE ... > GROUP BY `table1`.`id`"; > > mysql_query($sql); > > the problem is, that, when in table2 is not matching data using that id, > i lose that id from output array. but i don`t want to.. is there any > posibility to keep that id? > [/snip] > > More of a mysql question but do a left outer join with no group by > statement. > > SELECT table2.* > FROM table1 LEFT OUTER JOIN table2 > ON(table1.id = table2.id) > WHERE table1.id IS NULL > > > Returns all of table2 id's where there is no id in table1 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php - mysql problem
[snip] $sql = "SELECT * FROM `table1` LEFT JOIN `table2` USING `id` WHERE ... GROUP BY `table1`.`id`"; mysql_query($sql); the problem is, that, when in table2 is not matching data using that id, i lose that id from output array. but i don`t want to.. is there any posibility to keep that id? [/snip] More of a mysql question but do a left outer join with no group by statement. SELECT table2.* FROM table1 LEFT OUTER JOIN table2 ON(table1.id = table2.id) WHERE table1.id IS NULL Returns all of table2 id's where there is no id in table1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql problem- I know it isn't strictly php
Ross wrote: Hi all, I am trying to create a table on the remote server but it never seems to work CREATE TABLE `sheet1` ( `id` int(10) NOT NULL auto_increment, `title` varchar(255) NOT NULL default '', `fname` varchar(255) NOT NULL default '', `sname` varchar(255) default NULL, `job_title` varchar(255) default NULL, `organisation` varchar(255) default NULL, `email` varchar(255) default NULL, `street` varchar(255) default NULL, `city` varchar(255) default NULL, `postcode` varchar(255) default NULL, `office_tel` varchar(255) default NULL, `mobile` varchar(255) default NULL, `fax` varchar(255) default NULL, `web` varchar(255) default NULL, `add_info` varchar(255) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=303 ; There seems to be a problem with the last line (this is exported from my local server). I am just learning about mySql as I go so have no real clue about CHARSET and ENGINE (which I believe may be the problem) This is the error 1064 - 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 'DEFAULT CHARSET=latin1 AUTO_INCREMENT=303' at line 18 and this is what the manual says (not very helpful) a.. Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d Any help will be appreciated. R. If you have phpMyAdmin installed, create the table there and then export the table structure - I have found this to be very reliable in the past. Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] mysql problem- I know it isn't strictly php
[snip] 1064 - 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 'DEFAULT CHARSET=latin1 AUTO_INCREMENT=303' at line 18 and this is what the manual says (not very helpful) a.. Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d Any help will be appreciated. [/snip] There is nothing PHP here, but you knew that when you pressed send. Really there are a lot of MySQL gurus on this list. There are a lot more on mysql@lists.mysql.com You're problem is likely related to the version of MySQL that you are running, perhaps it doesn't support CHARSET definitions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql problem- I know it isn't strictly php
Hi all, I am trying to create a table on the remote server but it never seems to work CREATE TABLE `sheet1` ( `id` int(10) NOT NULL auto_increment, `title` varchar(255) NOT NULL default '', `fname` varchar(255) NOT NULL default '', `sname` varchar(255) default NULL, `job_title` varchar(255) default NULL, `organisation` varchar(255) default NULL, `email` varchar(255) default NULL, `street` varchar(255) default NULL, `city` varchar(255) default NULL, `postcode` varchar(255) default NULL, `office_tel` varchar(255) default NULL, `mobile` varchar(255) default NULL, `fax` varchar(255) default NULL, `web` varchar(255) default NULL, `add_info` varchar(255) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=303 ; There seems to be a problem with the last line (this is exported from my local server). I am just learning about mySql as I go so have no real clue about CHARSET and ENGINE (which I believe may be the problem) This is the error 1064 - 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 'DEFAULT CHARSET=latin1 AUTO_INCREMENT=303' at line 18 and this is what the manual says (not very helpful) a.. Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d Any help will be appreciated. R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [mysql]Problem with PHP5
I have installed PHP5 and i get the following error from a script that was working on PHP4 "Fatal error: Call to undefined function mysql_pconnect() in D:\htdocs\cdalex\Connections\listacon.php on line 9 " -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mysql Problem
Hi, I am generating a mysql statement and then printing it to a formatted field. Here is my code: $sql="SELECT * from tablename where name in ('Web','HTML','PHP') group by name; $mysql_rslt1 = mysql_query($sql, $mysql_bconn) or die ("Could not get data"); while ($rec1 = mysql_fetch_array ($mysql_rslt1)) { echo "some stuff here"; } Now the problem is it will leave out the last line of the reply. So it would leave out the 'PHP' line for the query above. Always the last line, and if for some reason i only have 1 in my query, it displays nothing, although if I do it manually using the mysql prompt, it works fine, and i get back the info I want. All the other lines format properly and the info is correct, just the last line doesnt display. Any ideas ? Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [PHP-DB] php-mysql problem
Jianping Zhu wrote: Hi, thank you for your respinse. It the /etc/php.ini i have something like: ; ; extension=modulename.extension ; ; For example: ; extension=mysql.so if you go to http://coopunit.forestry.uga.edu:8080/test.php you will find mysql is not installed as an extension. but i do not know how to fix this problem. Do i have to recomplie the phd from source code? Yes. See http://www.php.net/mysql for details. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
Jianping Zhu wrote: Thank you for your response. I get the php rpm distributed with redhat 9.0. Do I have to recompile phd instead from source code with mysql support? Thanks You need to install the php-mysql rpm. It will be on one of your Red Hat Discs. -- John C. Nichel KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
Thank you for your response. I get the php rpm distributed with redhat 9.0. Do I have to recompile phd instead from source code with mysql support? Thanks On Thu, May 13, 2004 at 06:15:23PM +0200, Oliver Hankeln wrote: > Hello, > > [snip] > > > but i got error message with: > > http://coopunit.forestry.uga.edu:8080/testdb.php > > the error is: > > Fatal error: Call to undefined function: > > mysql_connect() in /var/www/html/testdb.php on line 13 > > > > How can Fix this problem? Thanks > > [/snip] > > > Your PHP is compiled without mysql support (see > http://coopunit.forestry.uga.edu:8080/test.php) You do however have dbx > support. You might want to look at http://de.php.net/manual/de/ref.dbx.php > Your mysql_connect has to be replaced by dbx_connect and so on... > Alternativly you could recompile php with mysql support. > > HTH, > Oliver Hankeln > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [PHP-DB] php-mysql problem
Hi, thank you for your respinse. It the /etc/php.ini i have something like: ; ; extension=modulename.extension ; ; For example: ; extension=mysql.so if you go to http://coopunit.forestry.uga.edu:8080/test.php you will find mysql is not installed as an extension. but i do not know how to fix this problem. Do i have to recomplie the phd from source code? Thanks JP On Thu, May 13, 2004 at 07:24:28PM +0200, Stefan Dengscherz wrote: > hello, > > did you load the mysql module in your php.ini configuration file? > i.e. is the following line there: > extension=mysql.so > > regards > > On Thu, 13 May 2004 11:47:41 -0400 > Jianping Zhu <[EMAIL PROTECTED]> wrote: > > > have redhat 9.0 and Server version: Apache/2.0.40. > > i have installed rpms php-4.2.2-17.2.i386.rpm > >php-mysql-4.2.2-17.2.i386.rpm > > > > > >After i create a database called mydb and serveral tables in mysql, > >I tried to run following testdb.php script > > > > > >-- > > > > > > >$db = mysql_connect("localhost", "root","xx"); > >mysql_select_db("mydb",$db); > >$result = mysql_query("SELECT * FROM employees",$db); > >printf("First Name: %s\n", mysql_result($result,0,"first")); > >printf("Last Name: %s\n", mysql_result($result,0,"last")); > >printf("Address: %s\n", mysql_result($result,0,"address")); > >printf("Position: %s\n", mysql_result($result,0,"position")); > >?> > > > > > >--- > > > >but i got error message with: > >http://coopunit.forestry.uga.edu:8080/testdb.php > >the error is: > >Fatal error: Call to undefined function: > >mysql_connect() in /var/www/html/testdb.php on line 13 > > > >How can Fix this problem? Thanks > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php-mysql problem
Hello, [snip] but i got error message with: http://coopunit.forestry.uga.edu:8080/testdb.php the error is: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/testdb.php on line 13 How can Fix this problem? Thanks [/snip] Your PHP is compiled without mysql support (see http://coopunit.forestry.uga.edu:8080/test.php) You do however have dbx support. You might want to look at http://de.php.net/manual/de/ref.dbx.php Your mysql_connect has to be replaced by dbx_connect and so on... Alternativly you could recompile php with mysql support. HTH, Oliver Hankeln -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php-mysql problem
I have redhat 9.0 and Server version: Apache/2.0.40. i have installed rpms php-4.2.2-17.2.i386.rpm php-mysql-4.2.2-17.2.i386.rpm After i create a database called mydb and serveral tables in mysql, I tried to run following testdb.php script -- \n", mysql_result($result,0,"first")); printf("Last Name: %s\n", mysql_result($result,0,"last")); printf("Address: %s\n", mysql_result($result,0,"address")); printf("Position: %s\n", mysql_result($result,0,"position")); ?> --- but i got error message with: http://coopunit.forestry.uga.edu:8080/testdb.php the error is: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/testdb.php on line 13 How can Fix this problem? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP /MySQL problem on SMP machines
Hi Curt, Thanks for your email - please find answers below: Regards -- Lasse Laursen · VP, Hosting Technology · NetGroup A/S St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark Phone: +45 3370 1526 · Fax: +45 3313 0066 - Don't be fooled by cheap finnish imitations - BSD is the One True Code - Original Message - From: "Curt Zirzow" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, April 25, 2004 5:52 PM Subject: Re: [PHP] PHP /MySQL problem on SMP machines > * Thus wrote Lasse Laursen ([EMAIL PROTECTED]): > > Hi all, > > > > We just installed PHP 4.3.6 on FreeBSD 5.2.1 on some SMP machines and we are > > experiencing some weird problems. > > > >... > > > > The database backend is MySQL 4.0.18 and is run on a seperate dedicated > > server. > > What mysqlclient is php linked to? > php -i | grep "Client API" > > I would make sure you're using a 4.x version. webnode2# ./php -i | grep "Client API" Client API version 3.23.49 That could be one of the problems - how do I specify that I wish to use the 4.x API? > > Last night some problems occured - when we queried the databases for simple > > queries that _should_ return some rows (and worked minutes before) the > > database simply returned 0 rows. A restart og the mysqld and the php > > processes solved the problems but they return at random. > > A couple things to check: > - the output of mysql_error(), it usually solves 90% of query > problems. > > - if myismchk was ran on the table(s) mysql can get confused > about the indexes (until the table(s) are flushed) No errors occur that give an mysql_error at any time. Queries on the database simply returns the "wrong" information... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP /MySQL problem on SMP machines
* Thus wrote Lasse Laursen ([EMAIL PROTECTED]): > Hi all, > > We just installed PHP 4.3.6 on FreeBSD 5.2.1 on some SMP machines and we are > experiencing some weird problems. > >... > > The database backend is MySQL 4.0.18 and is run on a seperate dedicated > server. What mysqlclient is php linked to? php -i | grep "Client API" I would make sure you're using a 4.x version. > > Last night some problems occured - when we queried the databases for simple > queries that _should_ return some rows (and worked minutes before) the > database simply returned 0 rows. A restart og the mysqld and the php > processes solved the problems but they return at random. A couple things to check: - the output of mysql_error(), it usually solves 90% of query problems. - if myismchk was ran on the table(s) mysql can get confused about the indexes (until the table(s) are flushed) Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP /MySQL problem on SMP machines
Hi all, We just installed PHP 4.3.6 on FreeBSD 5.2.1 on some SMP machines and we are experiencing some weird problems. The PHP processes are running as FastCGI under Zeus with these compile options: ./configure --with-curl \ --enable-sockets \ --enable-dbx \ --with-jpeg-dir \ --with-jpeg \ --prefix=/webdisk/local/progs/php/compiled/4.3.6 \ --with-imlib \ --with-mysql \ --with-gd \ --enable-fastcgi \ --with-config-file-path=/webdisk/servers/php \ --with-exec-dir=/webdisk/servers/php/exec-dir \ --enable-memory-limit \ --disable-force-cgi-redirect \ --disable-url-fopen-wrapper \ --enable-track-vars \ --enable-xslt \ --with-xslt-sablot \ --enable-inline-optimization \ --disable-debug \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --with-ttf \ --with-freetype-dir=/usr/local/include/freetype2/ \ --with-zlib-dir=/usr/src/lib/libz/ \ --enable-gd-native-ttf \ The database backend is MySQL 4.0.18 and is run on a seperate dedicated server. Last night some problems occured - when we queried the databases for simple queries that _should_ return some rows (and worked minutes before) the database simply returned 0 rows. A restart og the mysqld and the php processes solved the problems but they return at random. I suspect that it is some weird problem with PHP / MySQL / SMP but I have no clue what can cause the problem. The old servers we used before the upgrade are all uni processor machines and we haven't experienced any similar problems on those machines. The sysctl for FreeBSD is set to: kern.ipc.shm_use_phys=1 (used on the old setup as well) Is there any issues with the mysql library under PHP that can cause the problems on the server - eg. not thread safe? I do hope that any of you have some pointers so I can get over this weird problem. Thanks in advance. Regards -- Lasse Laursen · VP, Hosting Technology · NetGroup A/S St. Kongensgade 40H · DK-1264 Copenhagen K, Denmark Phone: +45 3370 1526 · Fax: +45 3313 0066 - Don't be fooled by cheap finnish imitations - BSD is the One True Code -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP, MySQL problem
Hi Add records with this code. name address Hope this helps. Jan "Nicolai Elmqvist" <[EMAIL PROTECTED]> skrev i meddelandet news:[EMAIL PROTECTED] > Hi > > I have just started working with PHP and MySQL and have gone through 3 > tutorials on how to add and delete records from a database. Nearly > everything is working, as it should except for the communication between > HTML and PHP. If I try to add a record to my database by pushing a > "submit" the text in the textboxes are deleted but no record is inserted in > the database. I have copied the code directly form the tutorials so spelling > mistakes should not be the problem. > > > > It is possible to add records manually in the code so the connection to and > from the database is ok. > > > > So, does anybody know what I the problem might be? > > > > I'm using PHP 4.3.4, MySQL 4.0.17 and an Apache server. > > > > On before hand, thank you. > > Nicolai Elmqvist -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP,MySQL problem
Hello Nicolai, Wednesday, January 14, 2004, 12:14:09 PM, you wrote: NE> Sorry, I should have done that from the beginning, but here it is. I have NE> looked further on the variables and it seams like the name attribute NE> "sumbit" (in the ) is not converted to the $submit variable when I NE> if ($submit) { You probably have Register Globals turned off (you should do anyway, PHP by default has this setting now). That article looks like it assumed they were turned on. Simple solution: if ($_POST['submit']) You'll need to do this for each variable you want to use that comes in via the form. -- Best regards, Richardmailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP,MySQL problem
Sorry, I should have done that from the beginning, but here it is. I have looked further on the variables and it seams like the name attribute "sumbit" (in the ) is not converted to the $submit variable when I press the button. If I make a var_dump() in the beginning and end of the code, $submit is set to NULL in both occations. The same goes with the rest of the variables. It's like the conversion part is out of order, but where can I fix that? It is possible to update the database by setting the variables directly in the code, so that is not the problem. I have gone though my php.ini and httpd.conf files to see if there was any mistakes. Found one but it didn't solve the problem. Hope somebody can help. Thanks! The tutorial i have copied the code from can be found at: http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html Here is the code for making the database if anyone would like to test it. CREATE TABLE employees ( id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id)); Here is the script! Index "; } elseif ($delete) { // delete a record $sql = "DELETE FROM employees WHERE id=$id"; $result = mysql_query($sql); echo "$sql Record deleted!"; } else { // this part happens if we don't press submit if (!$id) { // print the list if there is not editing $result = mysql_query("SELECT * FROM employees",$db); while ($myrow = mysql_fetch_array($result)) { printf("%s %s \n", $PHP_SELF, $myrow["id"], $myrow["first"], $myrow["last"]); printf("(DELETE)", $PHP_SELF, $myrow["id"]); } } ?> ADD A RECORD First name: Last name: Address: Position: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP, MySQL problem
> So, does anybody know what I the problem might be? Hi, Well you need to post the code so one can see what's the problem Humberto Silva World Editing Portugal -Original Message- From: Nicolai Elmqvist [mailto:[EMAIL PROTECTED] Sent: quarta-feira, 14 de Janeiro de 2004 0:11 To: [EMAIL PROTECTED] Subject: [PHP] PHP, MySQL problem Hi I have just started working with PHP and MySQL and have gone through 3 tutorials on how to add and delete records from a database. Nearly everything is working, as it should except for the communication between HTML and PHP. If I try to add a record to my database by pushing a "submit" the text in the textboxes are deleted but no record is inserted in the database. I have copied the code directly form the tutorials so spelling mistakes should not be the problem. It is possible to add records manually in the code so the connection to and from the database is ok. So, does anybody know what I the problem might be? I'm using PHP 4.3.4, MySQL 4.0.17 and an Apache server. On before hand, thank you. Nicolai Elmqvist -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP, MySQL problem
Hi I have just started working with PHP and MySQL and have gone through 3 tutorials on how to add and delete records from a database. Nearly everything is working, as it should except for the communication between HTML and PHP. If I try to add a record to my database by pushing a "submit" the text in the textboxes are deleted but no record is inserted in the database. I have copied the code directly form the tutorials so spelling mistakes should not be the problem. It is possible to add records manually in the code so the connection to and from the database is ok. So, does anybody know what I the problem might be? I'm using PHP 4.3.4, MySQL 4.0.17 and an Apache server. On before hand, thank you. Nicolai Elmqvist -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-Mysql problem
> I just installed RedHat Linux 9.0 with Apache/Php/MySql for a project. I > have Apache and PHP running. However, PHP does not have the Mysql module?? > installed and this is the key to our project. Could someone point me in the > right direction to recompile PHP with proper MySql module included?? I am a > EXTREME newbie when it comes to compiling anything in Linux. Did you install apache/php/mysql as rpms? If you did then all you need to do is install the php-mysql rpm. -- Ray -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-Mysql problem
This is a good tutorial and it starts off with installiing php and mysql http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html Robin Kopetzky wrote: Good Afternoon!! I just installed RedHat Linux 9.0 with Apache/Php/MySql for a project. I have Apache and PHP running. However, PHP does not have the Mysql module?? installed and this is the key to our project. Could someone point me in the right direction to recompile PHP with proper MySql module included?? I am a EXTREME newbie when it comes to compiling anything in Linux. Robin 'Sparky' Kopetzky Black Mesa Computers/Internet Service Grants, NM 87020 -- +-+-++ | Blake Schroeder | Owner/Developer |lhwd.net| +--(http://www.lhwd.net)+--/3174026352\--+ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP-Mysql problem
Good Afternoon!! I just installed RedHat Linux 9.0 with Apache/Php/MySql for a project. I have Apache and PHP running. However, PHP does not have the Mysql module?? installed and this is the key to our project. Could someone point me in the right direction to recompile PHP with proper MySql module included?? I am a EXTREME newbie when it comes to compiling anything in Linux. Robin 'Sparky' Kopetzky Black Mesa Computers/Internet Service Grants, NM 87020 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Problem
Felipe, I'm replying in spanish so you can understand better. El problema que tienes es que la variable $nueva_base esta vacia. Si deseas especificar el nombre con esa variable debes asignarle algun valor antes de llamarla, si lo que quieres es crear una base de datos que se llame nueva_base, debes quitarle el $. Ej. mysql_create_db("nueva_base"). Espero te ayude. Oscar F.- Felipe R. wrote: Hi everyone, first, sorry to all if my english is so poor. second, i have the follow question: when i create a existing MySQL DBase, what happend?? how can i avoid this problem?? i attached my create_table code. Thanks for all Creación de una Base de Datos Creando Base de Datos if (mysql_create_db("$nueva_base")) { print (" Base de Datos $nueva_base Creada Satisfactoriamente!!"); $db_list = mysql_list_dbs($connection); $indice=0; while($row = mysql_fetch_array($db_list)){ $bases[$indice]=$row[0]; $indice++; } mysql_close($connection); echo " Las Bases de Datos Disponibles son: "; for($aux = 0; $aux < $indice; $aux++) { echo " $bases[$aux]"; } }else{ print ("Ërror Creando la Base de Datos: ". mysql_error()); } ?> Volver a http://localhost/administrador.htm";>Administrador de Bases de Datos Volver a http://localhost/nueva_base.htm";>Crear un Base de Datos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Problem
Hi everyone, first, sorry to all if my english is so poor. second, i have the follow question: when i create a existing MySQL DBase, what happend?? how can i avoid this problem?? i attached my create_table code. Thanks for all Creación de una Base de Datos Creando Base de Datos $nueva_base Creada Satisfactoriamente!!"); $db_list = mysql_list_dbs($connection); $indice=0; while($row = mysql_fetch_array($db_list)){ $bases[$indice]=$row[0]; $indice++; } mysql_close($connection); echo " Las Bases de Datos Disponibles son: "; for($aux = 0; $aux < $indice; $aux++) { echo " $bases[$aux]"; } }else{ print ("Ërror Creando la Base de Datos: ". mysql_error()); } ?> Volver a http://localhost/administrador.htm";>Administrador de Bases de Datos Volver a http://localhost/nueva_base.htm";>Crear un Base de Datos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MySQL problem with RedHat 8
Hi Again, I already have it! (And it is the one from the distro) [daniel@p85 daniel]$ rpm -q php-mysql php-mysql-4.2.2-8.0.5 /daniel On Wed, 2003-01-15 at 02:19, Larry Brown wrote: > You need the php-mysql rpm do rpm -q php-mysql > Get the one from the distro > > Larry S. Brown > Dimension Networks, Inc. > (727) 723-8388 > > -Original Message- > From: Daniel Elenius [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, January 14, 2003 5:22 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] MySQL problem with RedHat 8 > > Yes, mysql.so is in /usr/lib/php4. The php.ini file has this in it: > > [daniel@p85 etc]$ grep mysql php.ini > ;extension=php_mysql.dll > extension=mysql.so > mysql.allow_persistent = On > mysql.max_persistent = -1 > mysql.max_links = -1 > ; Default port number for mysql_connect(). If unset, mysql_connect() > will use > ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the > mysql.default_port = > mysql.default_socket = > ; Default host for mysql_connect() (doesn't apply in safe mode). > mysql.default_host = > ; Default user for mysql_connect() (doesn't apply in safe mode). > mysql.default_user = > ; Default password for mysql_connect() (doesn't apply in safe mode). > ; *Any* user with PHP access can run 'echo > cfg_get_var("mysql.default_password") > mysql.default_password = > > > /daniel > > On Tue, 2003-01-14 at 23:17, Joseph W. Goff wrote: > > Make sure that the shared module is in the correct directory. > > Check your php.ini file to make sure but it is most likely at /usr/lib/php4 > > make sure that you have mysql.so > > ----- Original Message - > > From: "Daniel Elenius" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Tuesday, January 14, 2003 3:58 PM > > Subject: [PHP] MySQL problem with RedHat 8 > > > > > > > Hi! > > > > > > I'm trying to connect to my mysql database using something like > > > > > > mysql_connect( 'localhost', 'root', 'thepassword' ) > > > or die ( 'Unable to connect to server.' ); > > > > > > But I get the error message: > > > Fatal error: Call to undefined function: mysql_connect() in > > > /home/daniel/public_html/index.php on line 21 > > > > > > I have: > > > > > > [root@p85 /]# rpm -qa |grep sql > > > php-mysql-4.2.2-8.0.5 > > > mysql-3.23.52-3 > > > mysql-server-3.23.52-3 > > > mysql-devel-3.23.52-3 > > > > > > and: > > > > > > [root@p85 /]# rpm -q php > > > php-4.2.2-8.0.5 > > > > > > Someone mentioned these two settings in php.ini, which I tried with no > > > success: > > > > > > register_globals = On > > > short_open_tag = On > > > > > > phpinfo() says that php was compiled with '--with-mysql=shared,/usr' > > > > > > Can someone help me please? > > > > > > regards, > > > -- > > > Daniel Elenius <[EMAIL PROTECTED]> > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > Daniel Elenius <[EMAIL PROTECTED]> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Daniel Elenius <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL problem with RedHat 8
Yes, mysql.so is in /usr/lib/php4. The php.ini file has this in it: [daniel@p85 etc]$ grep mysql php.ini ;extension=php_mysql.dll extension=mysql.so mysql.allow_persistent = On mysql.max_persistent = -1 mysql.max_links = -1 ; Default port number for mysql_connect(). If unset, mysql_connect() will use ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the mysql.default_port = mysql.default_socket = ; Default host for mysql_connect() (doesn't apply in safe mode). mysql.default_host = ; Default user for mysql_connect() (doesn't apply in safe mode). mysql.default_user = ; Default password for mysql_connect() (doesn't apply in safe mode). ; *Any* user with PHP access can run 'echo cfg_get_var("mysql.default_password") mysql.default_password = /daniel On Tue, 2003-01-14 at 23:17, Joseph W. Goff wrote: > Make sure that the shared module is in the correct directory. > Check your php.ini file to make sure but it is most likely at /usr/lib/php4 > make sure that you have mysql.so > - Original Message - > From: "Daniel Elenius" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, January 14, 2003 3:58 PM > Subject: [PHP] MySQL problem with RedHat 8 > > > > Hi! > > > > I'm trying to connect to my mysql database using something like > > > > mysql_connect( 'localhost', 'root', 'thepassword' ) > > or die ( 'Unable to connect to server.' ); > > > > But I get the error message: > > Fatal error: Call to undefined function: mysql_connect() in > > /home/daniel/public_html/index.php on line 21 > > > > I have: > > > > [root@p85 /]# rpm -qa |grep sql > > php-mysql-4.2.2-8.0.5 > > mysql-3.23.52-3 > > mysql-server-3.23.52-3 > > mysql-devel-3.23.52-3 > > > > and: > > > > [root@p85 /]# rpm -q php > > php-4.2.2-8.0.5 > > > > Someone mentioned these two settings in php.ini, which I tried with no > > success: > > > > register_globals = On > > short_open_tag = On > > > > phpinfo() says that php was compiled with '--with-mysql=shared,/usr' > > > > Can someone help me please? > > > > regards, > > -- > > Daniel Elenius <[EMAIL PROTECTED]> > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Daniel Elenius <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL problem with RedHat 8
Make sure that the shared module is in the correct directory. Check your php.ini file to make sure but it is most likely at /usr/lib/php4 make sure that you have mysql.so - Original Message - From: "Daniel Elenius" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, January 14, 2003 3:58 PM Subject: [PHP] MySQL problem with RedHat 8 > Hi! > > I'm trying to connect to my mysql database using something like > > mysql_connect( 'localhost', 'root', 'thepassword' ) > or die ( 'Unable to connect to server.' ); > > But I get the error message: > Fatal error: Call to undefined function: mysql_connect() in > /home/daniel/public_html/index.php on line 21 > > I have: > > [root@p85 /]# rpm -qa |grep sql > php-mysql-4.2.2-8.0.5 > mysql-3.23.52-3 > mysql-server-3.23.52-3 > mysql-devel-3.23.52-3 > > and: > > [root@p85 /]# rpm -q php > php-4.2.2-8.0.5 > > Someone mentioned these two settings in php.ini, which I tried with no > success: > > register_globals = On > short_open_tag = On > > phpinfo() says that php was compiled with '--with-mysql=shared,/usr' > > Can someone help me please? > > regards, > -- > Daniel Elenius <[EMAIL PROTECTED]> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL problem with RedHat 8
Hi! I'm trying to connect to my mysql database using something like mysql_connect( 'localhost', 'root', 'thepassword' ) or die ( 'Unable to connect to server.' ); But I get the error message: Fatal error: Call to undefined function: mysql_connect() in /home/daniel/public_html/index.php on line 21 I have: [root@p85 /]# rpm -qa |grep sql php-mysql-4.2.2-8.0.5 mysql-3.23.52-3 mysql-server-3.23.52-3 mysql-devel-3.23.52-3 and: [root@p85 /]# rpm -q php php-4.2.2-8.0.5 Someone mentioned these two settings in php.ini, which I tried with no success: register_globals = On short_open_tag = On phpinfo() says that php was compiled with '--with-mysql=shared,/usr' Can someone help me please? regards, -- Daniel Elenius <[EMAIL PROTECTED]> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql problem
Look into the logs, they should be more verbose. How did you install the three. BB wrote: >I seem to have a php-mysql problem on my new Sun Qube3 (RH Linux). >php works fine, mysql works fine, apache works fine, only the combination of >the three seems troublesome. >php does not recognize commands like mysql_connect() >when trying to start phpMyAdmin I get: "cannot load MySQL extension" >In my php.ini >extension_dir is set correctly >and I un-commented >extension=mysql.so >What more is there I could try? >Thank you. >Bert Bulder, Amsterdam NL > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql problem
I seem to have a php-mysql problem on my new Sun Qube3 (RH Linux). php works fine, mysql works fine, apache works fine, only the combination of the three seems troublesome. php does not recognize commands like mysql_connect() when trying to start phpMyAdmin I get: "cannot load MySQL extension" In my php.ini extension_dir is set correctly and I un-commented extension=mysql.so What more is there I could try? Thank you. Bert Bulder, Amsterdam NL -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Problem
Hi everyone! I can't figure out why this doesn't work. The call to the CONNECT function works and it connects with no problem, and it does save the Resource ID in $this->DBLink[]...however, when CHOOSEDB is called, the Resource ID just saved is gone. $this->DBLink is just empty, and I can't figure out why... Can anyone offer insight on this one? class MySQL { var $DBLink = array(); function CONNECT ( $MyVars , $MyContents ) { $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . ":" . $MyVars[PORT] : $MyVars[HOST]; $this->DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); } function CHOOSEDB ( $MyVars , $MyContents ) { mysql_select_db( $MyVars[DATABASE] , $this->DBLink[$MyVars[LINK]] ); } } Thanks! Lewis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Problem with PHP
I understand about the concat function, but that doesn't really fit into my scheme of things I run all text for the web through a function SafeSQL so that values from the web don't make SQL error or potential hacks occur. All SafeSQL was doing (for mssql, access and just about any other db) was $text = preg_replace("/\'/","' + CHAR(39) + '",$text) so when SQL added the rows with a value of 0 instead of the string I was baffled. Shame mysql doesn't support inline concatenation "John Holmes" <[EMAIL PROTECTED]> wrote in message 000701c21d14$fc054370$b402a8c0@mango">news:000701c21d14$fc054370$b402a8c0@mango... > > INSERT INTO `contracts` (`key`, `content`) VALUES (1,'blah blah blah > > character 39 is a single speach mark '+CHAR(39)+' blah blah blah') > > That's because you are adding strings together, not concatenating them > (this isn't javascript!) > > Use CONCAT() in MySQL to join strings together. > > mysql> select 'this'+char(39)+'that'; > ++ > | 'this'+char(39)+'that' | > ++ > | 0 | > ++ > 1 row in set (0.03 sec) > > mysql> select concat('this',char(39),'that'); > ++ > | concat('this',char(39),'that') | > ++ > | this'that | > ++ > 1 row in set (0.01 sec) > > ---John Holmes... > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MySQL Problem with PHP
> INSERT INTO `contracts` (`key`, `content`) VALUES (1,'blah blah blah > character 39 is a single speach mark '+CHAR(39)+' blah blah blah') That's because you are adding strings together, not concatenating them (this isn't javascript!) Use CONCAT() in MySQL to join strings together. mysql> select 'this'+char(39)+'that'; ++ | 'this'+char(39)+'that' | ++ | 0 | ++ 1 row in set (0.03 sec) mysql> select concat('this',char(39),'that'); ++ | concat('this',char(39),'that') | ++ | this'that | ++ 1 row in set (0.01 sec) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Problem with PHP
I am using PHP and MySQL on a 2k dev box to be uploaded to a linux box I have a piece of SQL INSERT INTO `contracts` (`key`, `content`) VALUES (1,'blah blah blah character 39 is a single speach mark '+CHAR(39)+' blah blah blah') Instead of inserting: 'blah blah blah character 39 is a single speach mark ' blah blah blah It inserts 0 All variations work fine when there is no single speachies help? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL problem
Thanks so much guys, It was my user permissions all along. Funnily enough the book gives you guidelines on how to set them up, and sets up a fair few... but for some reason they selected the wrong user to use. Thanks very much for your help David and Brian- much appreciated. Yours, GF - Original Message - From: David Jackson To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED] Sent: Monday, December 31, 2001 2:41 AM Subject: Re: [PHP] MySQL problem I almost forgot add a or mysql_error() for each line like this: This will return "human readable error messges" Can you onto mysql database from command. mysql -u root -p mysql or mysql -u root mysql # A root password isn't usally get during install. if so: >select user,host,password from user; then: select user,host,db from db; My quesss you don't have any permission for the databases or to connect to local host. If this is correct do: GRANT ALL on db_name.* TO you@local host idendified by 'your_password'; > Hiya, > > Thanks for the quick reply. I used the PHP manual example and it > connects to the database successfully but cannot select the database. > > I'm not sure why this is? I've looked hard at it and I cannot see where > I have gone wrong. > > Thanks. > > GF. > - Original Message - > From: David Jackson > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Sent: Monday, December 31, 2001 1:48 AM > Subject: Re: [PHP] MySQL problem > > > Here's the example from the PHP manual: > The tutorial here are very helpfull: > http://www.melonfire.com/community/columns/trog/ > > -- David > >// Connecting, selecting database > $link = mysql_connect("mysql_host", "mysql_login", "mysql_password") > or die("Could not connect"); > print "Connected successfully"; > mysql_select_db("my_database") > or die("Could not select database"); > > // Performing SQL query > $query = "SELECT * FROM my_table"; > $result = mysql_query($query) > or die("Query failed"); > > // Printing results in HTML > print "\n"; > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > print "\t\n"; > foreach ($line as $col_value) { > print "\t\t$col_value\n"; > } > print "\t\n"; > } > print "\n"; > > // Closing connection > mysql_close($link); > ?> > > > > > > Hello, > > > > I am extremely new to MySQL and have never managed to get working > > smoothly with PHP before. I am trying really hard to understand how > > to work it, and am almost there. > > > > I have a problem which I do not know how to resolve and was > > wondering if anybody could help me. I have no idea what is wrong > > with the code and why I am getting the error message; > > > > Warning: Supplied argument is not a valid MySQL result resource in > > C:\apache\htdocs\sams\chapter10\results.php on line 47 > > > > I am currently using a book to aid me with MySQL, and this is an > > example from the book. It does not seem to work and I have no idea > > what I may have done wrong to obtain this warning. > > > > I have changed my login and password to question marks. > > > > > > > if (!$searchtype || !$searchterm) > > > > { > > echo "You have not entered search details. Please go back and > > try > > again."; > > > > exit; > > > > } > > > > > > $searchtype = addslashes($searchtype); > > > > $searchterm = addslashes($searchterm); > > > > @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123"); > > > > if (!$db) > > > > { > > echo "Error: Could not connect to database. Please try again > > later."; > > > > exit; > > > > } > > > > mysql_select_db("booktest"); > > > > $query = "select * from booktest where ".$searchtype." like > > '%".$searchterm."%'"; > > > > $result = mysql_query($query); > > > > $num_results = mysql_num_rows($result); > > > > echo "Number of bo
Re: [PHP] MySQL problem
I almost forgot add a or mysql_error() for each line like this: This will return "human readable error messges" Can you onto mysql database from command. mysql -u root -p mysql or mysql -u root mysql # A root password isn't usally get during install. if so: >select user,host,password from user; then: select user,host,db from db; My quesss you don't have any permission for the databases or to connect to local host. If this is correct do: GRANT ALL on db_name.* TO you@local host idendified by 'your_password'; > Hiya, > > Thanks for the quick reply. I used the PHP manual example and it > connects to the database successfully but cannot select the database. > > I'm not sure why this is? I've looked hard at it and I cannot see where > I have gone wrong. > > Thanks. > > GF. > - Original Message - > From: David Jackson > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Sent: Monday, December 31, 2001 1:48 AM > Subject: Re: [PHP] MySQL problem > > > Here's the example from the PHP manual: > The tutorial here are very helpfull: > http://www.melonfire.com/community/columns/trog/ > > -- David > >// Connecting, selecting database > $link = mysql_connect("mysql_host", "mysql_login", "mysql_password") > or die("Could not connect"); > print "Connected successfully"; > mysql_select_db("my_database") > or die("Could not select database"); > > // Performing SQL query > $query = "SELECT * FROM my_table"; > $result = mysql_query($query) > or die("Query failed"); > > // Printing results in HTML > print "\n"; > while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { > print "\t\n"; > foreach ($line as $col_value) { > print "\t\t$col_value\n"; > } > print "\t\n"; > } > print "\n"; > > // Closing connection > mysql_close($link); > ?> > > > > > > Hello, > > > > I am extremely new to MySQL and have never managed to get working > > smoothly with PHP before. I am trying really hard to understand how > > to work it, and am almost there. > > > > I have a problem which I do not know how to resolve and was > > wondering if anybody could help me. I have no idea what is wrong > > with the code and why I am getting the error message; > > > > Warning: Supplied argument is not a valid MySQL result resource in > > C:\apache\htdocs\sams\chapter10\results.php on line 47 > > > > I am currently using a book to aid me with MySQL, and this is an > > example from the book. It does not seem to work and I have no idea > > what I may have done wrong to obtain this warning. > > > > I have changed my login and password to question marks. > > > > > > > if (!$searchtype || !$searchterm) > > > > { > > echo "You have not entered search details. Please go back and > > try > > again."; > > > > exit; > > > > } > > > > > > $searchtype = addslashes($searchtype); > > > > $searchterm = addslashes($searchterm); > > > > @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123"); > > > > if (!$db) > > > > { > > echo "Error: Could not connect to database. Please try again > > later."; > > > > exit; > > > > } > > > > mysql_select_db("booktest"); > > > > $query = "select * from booktest where ".$searchtype." like > > '%".$searchterm."%'"; > > > > $result = mysql_query($query); > > > > $num_results = mysql_num_rows($result); > > > > echo "Number of books found: ".$num_results.""; > > > > for ($i=0; $i <$num_results; $i++) > > > > { > > > > $row = mysql_fetch_array($result); > > > > echo "".($i+1).". Title: "; > > > > echo stripslashes($row["title"]); > > > > echo "Author: "; > > > > echo stripslashes($row["author"]); > > > > echo "ISBN: "; > > > > echo stripslashes($row["isbn"]); > > > > echo "Price: "; > > > > echo stripslashes($row["price"]); > > > > echo ""; > > > > } > > > > ?> > > > > The problem seems to be around the lines of code; > > > > $result = mysql_query($query); > > > > $num_results = mysql_num_rows($result); > > > > Any assistance is appreciated. > > > > Yours, > > > > GF. > > > > _ > > Chat with friends online, try MSN Messenger: > > http://messenger.msn.com > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] To > > contact the list administrators, e-mail: > > [EMAIL PROTECTED] > > > -- -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL problem
* GoodFella ([EMAIL PROTECTED]) [Dec 30. 2001 21:10]: > Thanks for the quick reply. I used the PHP manual example and it connects > to the database successfully but cannot select the database. So you are using this line: > > mysql_select_db("booktest"); Correct? What does the server "say" in return? What is the error message? -- Brian Clark | Avoiding the general public since 1805! Fingerprint: 07CE FA37 8DF6 A109 8119 076B B5A2 E5FB E4D0 C7C8 You can't put a bag over someone's personality. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL problem
Hiya, Thanks for the quick reply. I used the PHP manual example and it connects to the database successfully but cannot select the database. I'm not sure why this is? I've looked hard at it and I cannot see where I have gone wrong. Thanks. GF. - Original Message - From: David Jackson To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, December 31, 2001 1:48 AM Subject: Re: [PHP] MySQL problem Here's the example from the PHP manual: The tutorial here are very helpfull: http://www.melonfire.com/community/columns/trog/ -- David \n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t\n"; foreach ($line as $col_value) { print "\t\t$col_value\n"; } print "\t\n"; } print "\n"; // Closing connection mysql_close($link); ?> > Hello, > > I am extremely new to MySQL and have never managed to get working > smoothly with PHP before. I am trying really hard to understand > how to work it, and am almost there. > > I have a problem which I do not know how to resolve and was > wondering if anybody could help me. I have no idea what is wrong > with the code and why I am getting the error message; > > Warning: Supplied argument is not a valid MySQL result resource in > C:\apache\htdocs\sams\chapter10\results.php on line 47 > > I am currently using a book to aid me with MySQL, and this is an > example from the book. It does not seem to work and I have no idea what > I may have done wrong to obtain this warning. > > I have changed my login and password to question marks. > > > if (!$searchtype || !$searchterm) > > { > echo "You have not entered search details. Please go back and try > again."; > > exit; > > } > > > $searchtype = addslashes($searchtype); > > $searchterm = addslashes($searchterm); > > @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123"); > > if (!$db) > > { > echo "Error: Could not connect to database. Please try again > later."; > > exit; > > } > > mysql_select_db("booktest"); > > $query = "select * from booktest where ".$searchtype." like > '%".$searchterm."%'"; > > $result = mysql_query($query); > > $num_results = mysql_num_rows($result); > > echo "Number of books found: ".$num_results.""; > > for ($i=0; $i <$num_results; $i++) > > { > > $row = mysql_fetch_array($result); > > echo "".($i+1).". Title: "; > > echo stripslashes($row["title"]); > > echo "Author: "; > > echo stripslashes($row["author"]); > > echo "ISBN: "; > > echo stripslashes($row["isbn"]); > > echo "Price: "; > > echo stripslashes($row["price"]); > > echo ""; > > } > > ?> > > The problem seems to be around the lines of code; > > $result = mysql_query($query); > > $num_results = mysql_num_rows($result); > > Any assistance is appreciated. > > Yours, > > GF. > > _ > Chat with friends online, try MSN Messenger: http://messenger.msn.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: > [EMAIL PROTECTED] --
Re: [PHP] MySQL problem
Here's the example from the PHP manual: The tutorial here are very helpfull: http://www.melonfire.com/community/columns/trog/ -- David \n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { print "\t\n"; foreach ($line as $col_value) { print "\t\t$col_value\n"; } print "\t\n"; } print "\n"; // Closing connection mysql_close($link); ?> > Hello, > > I am extremely new to MySQL and have never managed to get working > smoothly with PHP before. I am trying really hard to understand > how to work it, and am almost there. > > I have a problem which I do not know how to resolve and was > wondering if anybody could help me. I have no idea what is wrong > with the code and why I am getting the error message; > > Warning: Supplied argument is not a valid MySQL result resource in > C:\apache\htdocs\sams\chapter10\results.php on line 47 > > I am currently using a book to aid me with MySQL, and this is an > example from the book. It does not seem to work and I have no idea what > I may have done wrong to obtain this warning. > > I have changed my login and password to question marks. > > > if (!$searchtype || !$searchterm) > > { > echo "You have not entered search details. Please go back and try > again."; > > exit; > > } > > > $searchtype = addslashes($searchtype); > > $searchterm = addslashes($searchterm); > > @ $db = mysql_pconnect("mesh", "bookorama", "bookorama123"); > > if (!$db) > > { > echo "Error: Could not connect to database. Please try again > later."; > > exit; > > } > > mysql_select_db("booktest"); > > $query = "select * from booktest where ".$searchtype." like > '%".$searchterm."%'"; > > $result = mysql_query($query); > > $num_results = mysql_num_rows($result); > > echo "Number of books found: ".$num_results.""; > > for ($i=0; $i <$num_results; $i++) > > { > > $row = mysql_fetch_array($result); > > echo "".($i+1).". Title: "; > > echo stripslashes($row["title"]); > > echo "Author: "; > > echo stripslashes($row["author"]); > > echo "ISBN: "; > > echo stripslashes($row["isbn"]); > > echo "Price: "; > > echo stripslashes($row["price"]); > > echo ""; > > } > > ?> > > The problem seems to be around the lines of code; > > $result = mysql_query($query); > > $num_results = mysql_num_rows($result); > > Any assistance is appreciated. > > Yours, > > GF. > > _ > Chat with friends online, try MSN Messenger: http://messenger.msn.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: > [EMAIL PROTECTED] -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] MySQL problem
Hello, I am extremely new to MySQL and have never managed to get working smoothly with PHP before. I am trying really hard to understand how to work it, and am almost there. I have a problem which I do not know how to resolve and was wondering if anybody could help me. I have no idea what is wrong with the code and why I am getting the error message; Warning: Supplied argument is not a valid MySQL result resource in C:\apache\htdocs\sams\chapter10\results.php on line 47 I am currently using a book to aid me with MySQL, and this is an example from the book. It does not seem to work and I have no idea what I may have done wrong to obtain this warning. I have changed my login and password to question marks. Number of books found: ".$num_results.""; for ($i=0; $i <$num_results; $i++) { $row = mysql_fetch_array($result); echo "".($i+1).". Title: "; echo stripslashes($row["title"]); echo "Author: "; echo stripslashes($row["author"]); echo "ISBN: "; echo stripslashes($row["isbn"]); echo "Price: "; echo stripslashes($row["price"]); echo ""; } ?> The problem seems to be around the lines of code; $result = mysql_query($query); $num_results = mysql_num_rows($result); Any assistance is appreciated. Yours, GF. _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] PHP + MySQL problem (strange behavior)
Unfortunately, mysql returns no error string. MySQL doesn't appear to think it's an error, as it does apply changes to the row I'm trying to change, it simple isn't applying the CORRECT change to said row :) -Javier -Original Message- From: David Robley [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 05, 2001 4:59 PM To: Javier Muniz; '[EMAIL PROTECTED]' Subject: Re: [PHP] PHP + MySQL problem (strange behavior) On Thu, 6 Dec 2001 08:32, Javier Muniz wrote: > Hello, > > I'm having trouble determining what's going wrong with a MySQL query > that I'm doing from PHP. Now before you go blaming MySQL read on :) > > I have a table with the following columns: > id (int) > name (varchar 20) > starttime (int) > duration (int) > > now, i have a row that has a starttime of 60, when i attempt to do the > following update with PHP, it sets it to 0: > > "UPDATE mytable SET starttime=starttime-30 WHERE name = 'myname'" > > but when I run it from the MySQL command line, copy/pasted from the > code, it sets the value of starttime to 30 as expected. > > Anyone have any clue why this is? mysql_error() is a good debugging tool; it will return an error string that may be useful. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA A waist is a terrible thing to mind. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP + MySQL problem (strange behavior)
On Thu, 6 Dec 2001 08:32, Javier Muniz wrote: > Hello, > > I'm having trouble determining what's going wrong with a MySQL query > that I'm doing from PHP. Now before you go blaming MySQL read on :) > > I have a table with the following columns: > id (int) > name (varchar 20) > starttime (int) > duration (int) > > now, i have a row that has a starttime of 60, when i attempt to do the > following update with PHP, it sets it to 0: > > "UPDATE mytable SET starttime=starttime-30 WHERE name = 'myname'" > > but when I run it from the MySQL command line, copy/pasted from the > code, it sets the value of starttime to 30 as expected. > > Anyone have any clue why this is? mysql_error() is a good debugging tool; it will return an error string that may be useful. -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA A waist is a terrible thing to mind. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP + MySQL problem (strange behavior)
Hello, I'm having trouble determining what's going wrong with a MySQL query that I'm doing from PHP. Now before you go blaming MySQL read on :) I have a table with the following columns: id (int) name (varchar 20) starttime (int) duration (int) now, i have a row that has a starttime of 60, when i attempt to do the following update with PHP, it sets it to 0: "UPDATE mytable SET starttime=starttime-30 WHERE name = 'myname'" but when I run it from the MySQL command line, copy/pasted from the code, it sets the value of starttime to 30 as expected. Anyone have any clue why this is? Javier Muniz Chief Technology Officer Granicus, LTD. Tel: (415) 522-5216 Fax: (415) 522-5215 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] mySQL problem
The issue here is that you aren't getting an index of "Company" from that query. It is probably stored under the index of "UCASE(Company)". Try: $Query = "SELECT UCASE(Company) as ucCompany, Icons, ID,..."; Then the ucCompany field will contain your capitalized company data. Jon -Original Message- From: Niklas Lampén [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 2:22 AM To: Php-General Subject: [PHP] mySQL problem I'm having a wierd problem with mySQL query. $Query = "SELECT UCASE(Company), Icons, ID, LogoD FROM feComps"; returns right amount of rows, but field Company is empty. $Query = "SELECT Company, Icons, ID, LogoD FROM feComps."; works fine. First query works great when I run it in shell. What could cause this? Niklas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] mySQL problem
"SELECT UCASE(Company) AS Company" works great, thanks! Niklas -Original Message- From: Dimitris Kossikidis [mailto:[EMAIL PROTECTED]] Sent: 2. marraskuuta 2001 11:11 To: 'Niklas Lamp¨¦n' Cc: PHP General Subject: RE: [PHP] mySQL problem Try this $Query = "SELECT UCASE(Company) as company, Icons, ID, LogoD FROM feComps"; List ( $company, $icons, etc ) = mysql_fetch_row( ); > -Original Message- > From: Niklas Lamp¦Én [mailto:[EMAIL PROTECTED]] > Sent: Friday, November 02, 2001 10:22 AM > To: Php-General > Subject: [PHP] mySQL problem > > > I'm having a wierd problem with mySQL query. > > $Query = "SELECT UCASE(Company), Icons, ID, LogoD FROM feComps"; > > returns right amount of rows, but field Company is empty. > > $Query = "SELECT Company, Icons, ID, LogoD FROM feComps."; > > works fine. > > > First query works great when I run it in shell. What could cause this? > > > Niklas > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] mySQL problem
Try this $Query = "SELECT UCASE(Company) as company, Icons, ID, LogoD FROM feComps"; List ( $company, $icons, etc ) = mysql_fetch_row( ); > -Original Message- > From: Niklas Lamp&igr;n [mailto:[EMAIL PROTECTED]] > Sent: Friday, November 02, 2001 10:22 AM > To: Php-General > Subject: [PHP] mySQL problem > > > I'm having a wierd problem with mySQL query. > > $Query = "SELECT UCASE(Company), Icons, ID, LogoD FROM feComps"; > > returns right amount of rows, but field Company is empty. > > $Query = "SELECT Company, Icons, ID, LogoD FROM feComps."; > > works fine. > > > First query works great when I run it in shell. What could cause this? > > > Niklas > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] mySQL problem
Try this $Query = "SELECT UCASE(Company) as company, Icons, ID, LogoD FROM feComps"; List ( $company, $icons, etc ) = mysql_fetch_row( ); > -Original Message- > From: Niklas Lamp&igr;n [mailto:[EMAIL PROTECTED]] > Sent: Friday, November 02, 2001 10:22 AM > To: Php-General > Subject: [PHP] mySQL problem > > > I'm having a wierd problem with mySQL query. > > $Query = "SELECT UCASE(Company), Icons, ID, LogoD FROM feComps"; > > returns right amount of rows, but field Company is empty. > > $Query = "SELECT Company, Icons, ID, LogoD FROM feComps."; > > works fine. > > > First query works great when I run it in shell. What could cause this? > > > Niklas > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] mySQL problem
I'm having a wierd problem with mySQL query. $Query = "SELECT UCASE(Company), Icons, ID, LogoD FROM feComps"; returns right amount of rows, but field Company is empty. $Query = "SELECT Company, Icons, ID, LogoD FROM feComps."; works fine. First query works great when I run it in shell. What could cause this? Niklas
RE: [PHP] MySQL problem
Sorry!!! I'm stupid! I forgot to mention that the list of causes has to be for a specified accident_report.weekending Cheers Simon > -Original Message- > From: Don Read [mailto:[EMAIL PROTECTED]] > Sent: 04 July 2001 23:21 > To: Simon Kimber > Cc: [EMAIL PROTECTED] > Subject: RE: [PHP] MySQL problem > > > > On 04-Jul-01 Simon Kimber wrote: > > Hi All, > > > > Does anyone know if this can be done with one query? > > > > I have to create a chart based on info in two tables that are > four tables > > apart. > > > > Here are the relevant tables and just the most relevant fields... > > > > accident_report > > - ID > > - weekending (this is a -MM-DD format date) > > - (and others) > > > > accident_data > > - ID > > - accident_report_id > > - (and others) > > > > accident_cause (a lookup table) > > - ID > > - accident_data_id > > - cause_id > > > > cause (a list of possible causes of accidents ie. "falling object" or > > "electric shock" > > - ID > > - Description > > > > > > I need to list all the causes with the number of times each has > occurred, > > even if it's zero times... they don't need to be listed in any > particular > > order... > > > > "select cause.ID, count(*) as cnt from ... > WHERE ... > group by cause.ID"; > > Regards, > -- > Don Read [EMAIL PROTECTED] > -- It's always darkest before the dawn. So if you are going to >steal the neighbor's newspaper, that's the time to do it. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MySQL problem
On 04-Jul-01 Simon Kimber wrote: > Hi All, > > Does anyone know if this can be done with one query? > > I have to create a chart based on info in two tables that are four tables > apart. > > Here are the relevant tables and just the most relevant fields... > > accident_report > - ID > - weekending (this is a -MM-DD format date) > - (and others) > > accident_data > - ID > - accident_report_id > - (and others) > > accident_cause (a lookup table) > - ID > - accident_data_id > - cause_id > > cause (a list of possible causes of accidents ie. "falling object" or > "electric shock" > - ID > - Description > > > I need to list all the causes with the number of times each has occurred, > even if it's zero times... they don't need to be listed in any particular > order... > "select cause.ID, count(*) as cnt from ... WHERE ... group by cause.ID"; Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] MySQL problem
Hi All, Does anyone know if this can be done with one query? I have to create a chart based on info in two tables that are four tables apart. Here are the relevant tables and just the most relevant fields... accident_report - ID - weekending (this is a -MM-DD format date) - (and others) accident_data - ID - accident_report_id - (and others) accident_cause (a lookup table) - ID - accident_data_id - cause_id cause (a list of possible causes of accidents ie. "falling object" or "electric shock" - ID - Description I need to list all the causes with the number of times each has occurred, even if it's zero times... they don't need to be listed in any particular order... Cheers Simon Kimber -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL problem...
Generally spoken, echo the SQL-Statement, and paste it in your local MySql Client (e.g. MySql-Font). These Frontends give you a better error, and you´ll find the problem in seconds. (hope so) ""Peter Houchin"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > some code would be nice to have a look at :) > > Other than that, check table names, database names, also your result lines, I've found i get that error by not calling a result or calling the incorrect table/database > > Peter > > -Original Message- > From: Brian Rue [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 26, 2001 10:28 AM > To: [EMAIL PROTECTED] > Subject: [PHP] MySQL problem... > > > MySQL doesn't like me > > Sometimes, my pages that connect to the database get the error "Warning: > Supplied argument is not a valid MySQL result resource..." repeated over and > over again (something like 1000 times...) > > What's causing this error? Obviously, PHP isn't getting a result back from > MySQL... and it keeps trying to get it. > > Any help? > > > Thanks, > Brian Rue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MySQL problem...
I think here's your problem: $query="INSERT INTO game_of_the_day VALUES ('',$curr_yday,'$gameone_genre',$gameone_number,'$gametwo_genre',$gametwo_nu mber)"; should look like : $query=" INSERT INTO game_of_the_day (ID, curr_yday, gameone_genre, gameone_number, gametwo_genre, gametwo_number) VALUES ('',$curr_yday,'$gameone_genre',$gameone_number,'$gametwo_genre',$gametwo_nu mber) "; try it. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Brian Rue [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 26, 2001 12:24 PM To: [EMAIL PROTECTED] Subject: Re: [PHP] MySQL problem... Here's all the code that uses MySQL... $db = mysql_connect("localhost","user","pass"); mysql_select_db("db",$db); $gmdquery="SELECT * FROM game_of_the_day"; $the_info = mysql_query($gmdquery,$db); while ($myrow = mysql_fetch_row($the_info)) { (get info from the result) } ... (decide whether or not to conduct the following operation) if (true) { $query="SELECT id FROM games WHERE rating >= 7"; $result=mysql_query($query,$db); $numgames=mysql_num_rows($result); $z=0; while ($row=mysql_fetch_row($result)){ $gotd_cand[$z]=$row[0]; $z++; } (at this point, i randomly select 2 games from the db) $query="SELECT genre,number FROM games WHERE id=$game1_to_get"; $gameinfo=mysql_query($query,$db); while($row=mysql_fetch_row($gameinfo)){ (use the result) } (do the same thing as before, but for the second game) } (update the db) $query="DELETE FROM game_of_the_day"; $result=mysql_query($query,$db); $query="INSERT INTO game_of_the_day VALUES ('',$curr_yday,'$gameone_genre',$gameone_number,'$gametwo_genre',$gametwo_nu mber)"; $result=mysql_query($query,$db); } Keep in mind that this only happens some of the time... sometimes it works, and sometimes it just doesn't. Today, I noticed that it stored the first game into the db twice (the code doesn't allow for the same game to be selected twice...) Thanks for your time ""Peter Houchin"" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > some code would be nice to have a look at :) > > Other than that, check table names, database names, also your result lines, I've found i get that error by not calling a result or calling the incorrect table/database > > Peter > > -Original Message- > From: Brian Rue [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 26, 2001 10:28 AM > To: [EMAIL PROTECTED] > Subject: [PHP] MySQL problem... > > > MySQL doesn't like me > > Sometimes, my pages that connect to the database get the error "Warning: > Supplied argument is not a valid MySQL result resource..." repeated over and > over again (something like 1000 times...) > > What's causing this error? Obviously, PHP isn't getting a result back from > MySQL... and it keeps trying to get it. > > Any help? > > > Thanks, > Brian Rue > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] MySQL problem...
Here's all the code that uses MySQL... $db = mysql_connect("localhost","user","pass"); mysql_select_db("db",$db); $gmdquery="SELECT * FROM game_of_the_day"; $the_info = mysql_query($gmdquery,$db); while ($myrow = mysql_fetch_row($the_info)) { (get info from the result) } ... (decide whether or not to conduct the following operation) if (true) { $query="SELECT id FROM games WHERE rating >= 7"; $result=mysql_query($query,$db); $numgames=mysql_num_rows($result); $z=0; while ($row=mysql_fetch_row($result)){ $gotd_cand[$z]=$row[0]; $z++; } (at this point, i randomly select 2 games from the db) $query="SELECT genre,number FROM games WHERE id=$game1_to_get"; $gameinfo=mysql_query($query,$db); while($row=mysql_fetch_row($gameinfo)){ (use the result) } (do the same thing as before, but for the second game) } (update the db) $query="DELETE FROM game_of_the_day"; $result=mysql_query($query,$db); $query="INSERT INTO game_of_the_day VALUES ('',$curr_yday,'$gameone_genre',$gameone_number,'$gametwo_genre',$gametwo_nu mber)"; $result=mysql_query($query,$db); } Keep in mind that this only happens some of the time... sometimes it works, and sometimes it just doesn't. Today, I noticed that it stored the first game into the db twice (the code doesn't allow for the same game to be selected twice...) Thanks for your time ""Peter Houchin"" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > some code would be nice to have a look at :) > > Other than that, check table names, database names, also your result lines, I've found i get that error by not calling a result or calling the incorrect table/database > > Peter > > -Original Message- > From: Brian Rue [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 26, 2001 10:28 AM > To: [EMAIL PROTECTED] > Subject: [PHP] MySQL problem... > > > MySQL doesn't like me > > Sometimes, my pages that connect to the database get the error "Warning: > Supplied argument is not a valid MySQL result resource..." repeated over and > over again (something like 1000 times...) > > What's causing this error? Obviously, PHP isn't getting a result back from > MySQL... and it keeps trying to get it. > > Any help? > > > Thanks, > Brian Rue > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MySQL problem...
it might also be the characters escaping. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Brian Rue [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 26, 2001 9:28 AM To: [EMAIL PROTECTED] Subject: [PHP] MySQL problem... MySQL doesn't like me Sometimes, my pages that connect to the database get the error "Warning: Supplied argument is not a valid MySQL result resource..." repeated over and over again (something like 1000 times...) What's causing this error? Obviously, PHP isn't getting a result back from MySQL... and it keeps trying to get it. Any help? Thanks, Brian Rue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] MySQL problem...
MySQL doesn't like me Sometimes, my pages that connect to the database get the error "Warning: Supplied argument is not a valid MySQL result resource..." repeated over and over again (something like 1000 times...) What's causing this error? Obviously, PHP isn't getting a result back from MySQL... and it keeps trying to get it. Any help? Thanks, Brian Rue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] MySQL problem...
some code would be nice to have a look at :) Other than that, check table names, database names, also your result lines, I've found i get that error by not calling a result or calling the incorrect table/database Peter -Original Message- From: Brian Rue [mailto:[EMAIL PROTECTED]] Sent: Thursday, April 26, 2001 10:28 AM To: [EMAIL PROTECTED] Subject: [PHP] MySQL problem... MySQL doesn't like me Sometimes, my pages that connect to the database get the error "Warning: Supplied argument is not a valid MySQL result resource..." repeated over and over again (something like 1000 times...) What's causing this error? Obviously, PHP isn't getting a result back from MySQL... and it keeps trying to get it. Any help? Thanks, Brian Rue -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]