danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Each time it has come back with "Customer not found". Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744388 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 after the dbQuery() line, put this: print_r($results); and tell me what it outputs Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744399 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Nothing. It didn't print out the error that it had been but it didn't print out anything else either. Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744403 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 weird...how about this: <?php include 'common.php'; dbConnect(); $c = dbQuery("SELECT * FROM customers c LEFT JOIN orders o ON c.customer_id=o.customer_id WHERE c.customer_id = %1", $_GET['customer_id']); print "<pre>Counter: $c\nResults:\n"; print_r($results); exit; if(!is_array($results[$c]) || !count($results[$c])) die("Customer not found"); $customer = mysql_fetch_assoc($results[$c]); ?> <html> <head> <Title>Edit Customer</title> </head> <body> <table> <tr> <td><input type="text" style="width:148px" name="FirstName" value="<?php echo $customer['first_name']; ?>"/></td> </tr> </table> </body> </html> <? dbClose(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744412 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Counter: 1 Results: Array ( [1] => Resource id #4 ) Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744422 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 ok...that is good...now what about this: <?php include 'common.php'; dbConnect(); $c = dbQuery("SELECT * FROM customers c LEFT JOIN orders o ON c.customer_id=o.customer_id WHERE c.customer_id = %1", $_GET['customer_id']); print "Rows: ".mysql_num_rows($results[$c]); exit; if(!is_array($results[$c]) || !count($results[$c])) die("Customer not found"); $customer = mysql_fetch_assoc($results[$c]); ?> <html> <head> <Title>Edit Customer</title> </head> <body> <table> <tr> <td><input type="text" style="width:148px" name="FirstName" value="<?php echo $customer['first_name']; ?>"/></td> </tr> </table> </body> </html> <? dbClose(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744429 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Rows: 4 Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744445 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 wow...ok...i should have looked at the query before...this is for editing customer info right? why do you join it with the orders table? Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744453 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Some of the data which I need to edit comes from the orders table. Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744459 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Come to think of it perhaps I do not need the orders table, however I do not see how that would make much of a difference. Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744464 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 well...the join will produce a row for each order, instead of each customer. truthfully, every row should have the customer info, so that shouldn't be a problem. anyways, try this then: <?php include 'common.php'; dbConnect(); $c = dbQuery("SELECT * FROM customers c LEFT JOIN orders o ON c.customer_id=o.customer_id WHERE c.customer_id = %1", $_GET['customer_id']); print "<pre>Rows: ".mysql_num_rows($results[$c])."\nFirst Row:\n"; print_r(mysql_fetch_assoc($results[$c])); exit; if(!is_array($results[$c]) || !count($results[$c])) die("Customer not found"); $customer = mysql_fetch_assoc($results[$c]); ?> <html> <head> <Title>Edit Customer</title> </head> <body> <table> <tr> <td><input type="text" style="width:148px" name="FirstName" value="<?php echo $customer['first_name']; ?>"/></td> </tr> </table> </body> </html> <? dbClose(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744478 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Rows: 4 First Row: Array ( [customer_id] => 21249 [first_name] => * [last_name] => * [care_of] => [address] => * [ups_address] => [city] => Ames [states] => IA [zip] => 50010 [country_id] => 0 [email_address] => * [phone_number] => * [fax_number] => * [reseller] => 0 [consultant] => 0 [support_id] => 2 [support_exp] => 0000-00-00 00:00:00 [group_id] => 0 [tax_id] => [business] => 0 [trac_count] => 0 [funds_count] => 0 [stock_count] => 0 [site_count] => 0 [combo_count] => 0 [first_contact] => Shannon Roder [sort_id] => [status_id] => 6 [date_entered] => 0000-00-00 00:00:00 [last_contact] => 0000-00-00 00:00:00 [last_pur_date] => 0000-00-00 00:00:00 [dealer_rating] => [type_of_computer] => [lit_status] => 0 [lit_date] => 0000-00-00 00:00:00 [cd_version] => 5 [order_id] => 358 [employee_id] => 5 [shipping_method] => Normal [ship_date] => 0000-00-00 00:00:00 [tax] => 0.00 [tax_amt] => 0.00 [ship_charge] => 0.00 [price_list] => Retail [packing_printed] => 1 [label_printed] => 1 [total_payment] => 0.00 [payment_method_id] => 4 [PO_number] => [CC_number] => * [CC_exp_date] => * [card_holder_name] => [CC_sent_to_bank] => 1 [COD_recieved] => 0 [can_print] => 1 [norm_has_seen] => 1 [comments] => [order_complete] => 0 [internet_order_id] => ) Note: Stars had data I however removed it for the post. Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744481 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 this this should work: <?php include 'common.php'; dbConnect(); $c = dbQuery("SELECT * FROM customers c LEFT JOIN orders o ON c.customer_id=o.customer_id WHERE c.customer_id = %1", $_GET['customer_id']); if(!mysql_num_rows($results[$c])) die("Customer not found"); $customer = mysql_fetch_assoc(mysql_fetch_assoc($results[$c])); ?> <html> <head> <Title>Edit Customer</title> </head> <body> <table> <tr> <td><input type="text" style="width:148px" name="FirstName" value="<?php echo $customer['first_name']; ?>"/></td> </tr> </table> </body> </html> <? dbClose(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744485 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 Empty text box again. Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744488 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 oops...had two mysql_fetch_assoc in there: <?php include 'common.php'; dbConnect(); $c = dbQuery("SELECT * FROM customers c LEFT JOIN orders o ON c.customer_id=o.customer_id WHERE c.customer_id = %1", $_GET['customer_id']); if(!mysql_num_rows($results[$c])) die("Customer not found"); $customer = mysql_fetch_assoc($results[$c]); ?> <html> <head> <Title>Edit Customer</title> </head> <body> <table> <tr> <td><input type="text" style="width:148px" name="FirstName" value="<?php echo $customer['first_name']; ?>"/></td> </tr> </table> </body> </html> <? dbClose(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744490 Share on other sites More sharing options...
danjoe_15 Posted January 23, 2009 Author Share Posted January 23, 2009 It is working now. Thank you very much for your help rhodesa. Sorry that it took so much time. Would you by any chance be able to tell me why it was that this worked and nothing else that I had tried did? Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744494 Share on other sites More sharing options...
rhodesa Posted January 23, 2009 Share Posted January 23, 2009 it should have worked a while ago, but i was having a brain fart. the changes that were made: -On the form, used full PHP tags, and added some spaces to make that echo work -In the EditCustomer.php, dbQuery() returns a integer. That integer refers to a key in the $results global variable -The value for that key in $results is a mysql resource, which you have to pull the row off using one of the mysql_fetch_* functions Quote Link to comment https://forums.phpfreaks.com/topic/142109-problems-with-get-method/page/2/#findComment-744502 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.