Re: [PHP] Simple Problem
PartyPosters wrote: I can't figure out what I am doing wrong, this sql string seems to filter out the information I want but it duplicates the all info, as 'num_rows' is total of rows in the table and not the correct value of the filtered information? $sql=SELECT products.productID, products.title, products.number_per_box, products.stock_level, products.image, users.username, users.email, users.userID FROM users, products WHERE products.userID = $userID; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); this is the old sql statement which works fine - $sql=SELECT productID, title, number_per_box, stock_level, image, userID FROM products WHERE userID = '$userID'; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); http://lists.mysql.com -- John C. Nichel ÜberGeek 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] Simple Problem
snip I can't figure out what I am doing wrong, this sql string seems to filter out the information I want but it duplicates the all info, as 'num_rows' is total of rows in the table and not the correct value of the filtered information? $sql=SELECT products.productID, products.title, products.number_per_box, products.stock_level, products.image, users.username, users.email, users.userID FROM users, products WHERE products.userID = $userID; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); this is the old sql statement which works fine - $sql=SELECT productID, title, number_per_box, stock_level, image, userID FROM products WHERE userID = '$userID'; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); what I am I doing wrong. /snip In the old query you're jut pulling records from one table. In the second, you're joining two tables, but you're still using the same WHERE clause, products.userID = $userID. This is causing multiple records to be returned, since there is nothing specifying how you are joining the users and products table so it correctly returns a match for every row in the user table. Change the where clause to: WHERE products.userID = $userID AND users.userID = $userID and this will force the query to limit results to those records in products that have a matching record in the users table. HTH. Pablo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Problem
Hello PartyPosters, Tuesday, April 12, 2005, 4:24:34 PM, you wrote: P I can't figure out what I am doing wrong, this sql string seems to P filter out the information I want but it duplicates the all info, P as 'num_rows' is total of rows in the table and not the correct P value of the filtered information? P $sql=SELECT products.productID, products.title, P products.number_per_box, products.stock_level, products.image, P users.username, users.email, users.userID FROM users, products P WHERE products.userID = $userID; P $mysql_result=mysql_query($sql,$connection); P $num_rows=mysql_num_rows($mysql_result); Your query should probably be performing a join. As it stands you're selecting all of the products where userID = $userID, but you're also selecting all of your users regardless (SELECT blah FROM users). What relationship does the Users table have to the Products table? You may need something more along the lines of: SELECT blah FROM products LEFT JOIN users ON users.UserID = products.UserID WHERE users.UserID = $userID But that's just a best-guess based on what you've given so far. Best regards, Richard Davey -- http://www.launchcode.co.uk - PHP Development Services I do not fear computers. I fear the lack of them. - Isaac Asimov -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Problem
On Tuesday 12 April 2005 16:24, PartyPosters typed: $sql=SELECT products.productID, products.title, products.number_per_box, products.stock_level, products.image, users.username, users.email, users.userID FROM users, products WHERE products.userID = $userID; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); You don't specify how the query should join the tables users and products. WHERE products.userID = users.userID and users.userID = $userID I'll assume you do validation on the userID ahead of time to ensure that it's the right format. -- My mind not only wanders, it sometimes leaves completely. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple Problem
I think what you mean/need is: $sql=SELECT products.productID, products.title, products.number_per_box, products.stock_level, products.image, users.username, users.email, users.userID FROM users, products WHERE products.userID = users.userID AND userID = $userID; John Nichel wrote: PartyPosters wrote: I can't figure out what I am doing wrong, this sql string seems to filter out the information I want but it duplicates the all info, as 'num_rows' is total of rows in the table and not the correct value of the filtered information? $sql=SELECT products.productID, products.title, products.number_per_box, products.stock_level, products.image, users.username, users.email, users.userID FROM users, products WHERE products.userID = $userID; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); this is the old sql statement which works fine - $sql=SELECT productID, title, number_per_box, stock_level, image, userID FROM products WHERE userID = '$userID'; $mysql_result=mysql_query($sql,$connection); $num_rows=mysql_num_rows($mysql_result); http://lists.mysql.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple problem about authentication
1lt John W. Holmes schrieb: I'm trying to set up a password section on my website. But I don't want a window popping up asking for a username and password. I'd rather like to have a form that submits the data. I did that and it works fine, but the browser seems to not save the username and password, because if i click on any link, it returns an unauthorized message... any ideas? thnx, Show some code... the possibilities are endless for what you're doing wrong. ---John Holmes... ok, here's the code: the form submits the user name and password in the variables $user and $pw to another site, which includes this: if(isset($user) isset($pw)){ $user = ucwords(strtolower($user)); $PHP_AUTH_USER = $user; $PHP_AUTH_PW = $pw;} if(isset($PHP_AUTH_USER)){ $result = mysql_query(select * from _users where user = '$PHP_AUTH_USER'); $_user = mysql_fetch_array($result);} if(!isset($PHP_AUTH_USER)) { header('HTTP/1.0 401 Unauthorized'); echo('unauthorized'); exit;} else{ $result = mysql_query(select * from _users where user = '$PHP_AUTH_USER') or die('Error occured while connecting to database'); $rows = mysql_num_rows($result); if($rows == 0){ header('HTTP/1.0 401 Unauthorized'); echoscriptwindow.location.href='../index.php?action=user_wrong'/script; exit;} else{ $daten = mysql_fetch_array($result); if($PHP_AUTH_PW == $daten['pw']){ // authorized } else{ header('HTTP/1.0 401 Unauthorized'); echoscriptwindow.location.href='../index.php?action=pw_wronguser=$user'/script; exit;}}} And this works fine for just this page. Whenever I click on a link to a page which includes the same file though, it echoes 'unauthorized'... Olli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple problem about authentication
At 14:22 26.02.2003, Oliver Witt spoke out and said: [snip] if(isset($user) isset($pw)){ $user = ucwords(strtolower($user)); $PHP_AUTH_USER = $user; $PHP_AUTH_PW = $pw;} [more...] And this works fine for just this page. Whenever I click on a link to a page which includes the same file though, it echoes 'unauthorized'... [snip] Sounds like you're using sessions... perhaps register_globals is off in your environment, so session variables are not registered? How do you set the $user and $pw variables? -- O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple problem about authentication
Ernest E Vogelsinger schrieb: At 14:22 26.02.2003, Oliver Witt spoke out and said: [snip] if(isset($user) isset($pw)){ $user = ucwords(strtolower($user)); $PHP_AUTH_USER = $user; $PHP_AUTH_PW = $pw;} [more...] And this works fine for just this page. Whenever I click on a link to a page which includes the same file though, it echoes 'unauthorized'... [snip] Sounds like you're using sessions... perhaps register_globals is off in your environment, so session variables are not registered? How do you set the $user and $pw variables? no, im not using sessions and register globals is on. the variables user and pw are set by submitting a form (method=post). that's where i expect the mistake to be. because as far as i know, the browser usually saves the credentials, at least the user name after authenticating. but it just doesn't seem to do so Olli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple problem about authentication
I'm trying to set up a password section on my website. But I don't want a window popping up asking for a username and password. I'd rather like to have a form that submits the data. I did that and it works fine, but the browser seems to not save the username and password, because if i click on any link, it returns an unauthorized message... any ideas? thnx, Show some code... the possibilities are endless for what you're doing wrong. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple problem
Inside the loop do: if(!($i%3)) { whatever } -Rasmus On Wed, 4 Sep 2002, Cirkit Braker wrote: what would be the best, most efficient way to print something every three times a loop runs for ($i=0; $i$num_products; $i++) { echo something; } this happens every time it runs and has to stay that way but every three times i want to print additional info. Any help appreciated. -- 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] simple problem
if ($i%3 = 0) { echo something; } On Wed, 4 Sep 2002, Cirkit Braker wrote: what would be the best, most efficient way to print something every three times a loop runs for ($i=0; $i$num_products; $i++) { echo something; } this happens every time it runs and has to stay that way but every three times i want to print additional info. Any help appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple problem
I need insert some variable ito log.txt file but every item (variable) must be on other line how to do this ? If I am understanding your question correctly, you need to add a newline character (\n) at then end every line. Like so: $fp1 = Fopen(D:\\log.txt,a+); fwrite($fp1,$start\n); fwrite($fp1,$array[0]\n); fwrite($fp1,$array[1]\n); . fwrite($fp1,$end); Fclose($fp1); HTH -jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Simple problem
Or you could just write snip $fp1 = Fopen(D:\\log.txt,a+); fwrite($fp1,$start\n$array[0]\n$array[1]\n); snip to simplify... -- Richard, oblivion creations http://oblivion.lunamorena.net [EMAIL PROTECTED] +4+ (0) 736 849 531 for sure contact.. Jeff Van Campen [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I need insert some variable ito log.txt file but every item (variable) must be on other line how to do this ? If I am understanding your question correctly, you need to add a newline character (\n) at then end every line. Like so: $fp1 = Fopen(D:\\log.txt,a+); fwrite($fp1,$start\n); fwrite($fp1,$array[0]\n); fwrite($fp1,$array[1]\n); . fwrite($fp1,$end); Fclose($fp1); HTH -jeff -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php