Re: [PHP-DB] Compatibility with PHP and MySQL

2011-09-05 Thread Chris Stinemetz
On Mon, Sep 5, 2011 at 3:49 PM, Gabriel Solberg solbergdes...@gmail.com wrote:
 Will installing the most recent XMAPP to install PHP MySQL and Apache to
 create a development environment on my local computer affect how everything
 runs when I upload it to the server (My web host 1and1.com runs php 5.0 and
 MySQL 5.0) thanks


You may notice differences if your php.ini and http.conf files are not
the same in both development and production environments. I would
compare them first.

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



[PHP-DB] foreign key

2011-08-09 Thread Chris Stinemetz
Okay. I am pretty new to mysql so this may seem like a ridiculous
question to some people.

I am trying to use a LEFT JOIN query, but the results I am finding
unusual. For every record occurrence there is for the query, the
results are duplicated by that amount.

So if there are 3 records from the query results, then the output is 3
times what I expect.. if that makes sense.

From what I have researched so far. I believe I may need to add a
foreign key to build the relations between the two tables.

Based on the query can any tell me the correct way of adding the
foreign key if ,in fact, that is what I need?

I can provide table structures and information if necessary.

The query is:

$posts_sql = SELECT
store_subject,
store_comments, 
store_date,
store_tptest,   
store_by,
users.user_id,
users.user_name,
users.first_name,
users.last_name
FROM
stores
LEFT JOIN
users
ON
stores.store_by = users.user_id
WHERE
stores.store_subject = ' . mysql_real_escape_string($_GET['id']).'
ORDER BY
stores.store_date DESC ;

The query dump is:

SELECT store_subject, store_comments, store_date, store_tptest,
store_by, users.user_id, users.user_name, users.first_name,
users.last_name FROM stores LEFT JOIN users ON stores.store_by =
users.user_id WHERE stores.store_subject = 'Noland Park Plaza 3509 S.
Noland Rd' ORDER BY stores.store_date DESC

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



Re: [PHP-DB] foreign key

2011-08-09 Thread Chris Stinemetz

 Is users.user_id unique?


yes it is.

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



Re: [PHP-DB] foreign key

2011-08-09 Thread Chris Stinemetz


 What does your result look like? Hard to say what the problem is
 without seeing the result.


I am echoing the query and printing the get array just for debugging
purposes, but below you can see how it is repeating its' self.

Thank you



Array
(
[id] = Bella Roe 4980 Roe Blvd
)

Bella Roe 4980 Roe BlvdSELECT stores.store_subject, stores.store_comments,
stores.store_date, stores.store_tptest, stores.store_by, users.user_id,
users.user_name, users.first_name, users.last_name FROM stores LEFT JOIN
users ON stores.store_by = users.user_id WHERE stores.store_subject = 'Bella
Roe 4980 Roe Blvd' ORDER BY stores.store_date DESC Chris Stinemetz
08-09-2011 02:08PM600kbps-3.8mbps
testChris Stinemetz
08-09-2011 02:07PM0-250kbps
test1Reply:


Bella Roe 4980 Roe BlvdSELECT stores.store_subject, stores.store_comments,
stores.store_date, stores.store_tptest, stores.store_by, users.user_id,
users.user_name, users.first_name, users.last_name FROM stores LEFT JOIN
users ON stores.store_by = users.user_id WHERE stores.store_subject = 'Bella
Roe 4980 Roe Blvd' ORDER BY stores.store_date DESC Chris Stinemetz
08-09-2011 02:08PM600kbps-3.8mbps
testChris Stinemetz
08-09-2011 02:07PM0-250kbps
test1Reply:


Re: [PHP-DB] foreign key

2011-08-09 Thread Chris Stinemetz
Okay. I just validated it is not in the left join query, but in my php. I
was able to build the correct relations.

Does anyone see any think in the php code below that may cause duplicate
table rows?

Thank you all.

?php
//store.php
include_once 'includes/connect.php';
include_once 'includes/header.php';
print(pre.print_r($_GET,true)./pre);
$sql = SELECT store_id, store_subject, store_comments, store_date,
store_tptest, store_by
 FROM stores
 WHERE store_subject = ' . mysql_real_escape_string($_GET['id']).';
$result = mysql_query($sql);
if(!$result)
{
 echo 'The latest post could not be displayed, please try again later.';
 //echo mysql_error(); //debugging purposes, uncomment when needed

}
else
{
 if(mysql_num_rows($result) == 0)
 {
  echo 'This store visit doesnprime;t exist.';
 }
 else
 {
  while($row = mysql_fetch_assoc($result))
  {
   //display post data
   echo 'table class=table1 border=1
 tr
  th colspan=2' . $row['store_subject'] . '/th
 /tr';

   //fetch the posts from the database
   $posts_sql = SELECT
  stores.store_subject,
  stores.store_comments,
  stores.store_date,
  stores.store_tptest,
  stores.store_by,
  users.user_id,
  users.user_name,
  users.first_name,
  users.last_name
 FROM
  stores
 LEFT JOIN
  users
 ON
  stores.store_by = users.user_id
 WHERE
  stores.store_subject = ' . mysql_real_escape_string($_GET['id']).'
 ORDER BY
  stores.store_date DESC ;

  //echo $posts_sql;

   $posts_result = mysql_query($posts_sql);

   if(!$posts_result)
   {
echo 'trtdThe posts could not be displayed, please try again
later./tr/td/table';
//echo mysql_error(); //debugging purposes, uncomment when needed
   }
   else
   {

while($posts_row = mysql_fetch_assoc($posts_result))
{
 echo 'tr class=topic-post
   td class=user-post' . $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . 'br/' . date('m-d-Y h:iA',
strtotime($posts_row['store_date'])) . '/td
   td class=post-content' . $posts_row['store_tptest'] . 'br/' .
htmlentities(stripslashes($posts_row['store_comments'])) . '/td
/tr';
}
   }

   if(!$_SESSION['signed_in'])
   {
echo 'trtd colspan=2You must be a href=signin.phpsigned in/a
to reply. You can also a href=signup.phpsign up/a for an account.';
   }
   else
   {
//show reply box
echo 'trtd colspan=2h2Reply:/h2br /
 form method=post action=reply.php?id=' . $row['store_id'] . '
  textarea name=reply-content/textareabr /br /
  input type=submit value=Submit reply /
 /form/td/tr';
   }

   //finish the table
   echo '/table';
  }
 }
}
include_once 'includes/footer.php';
?


[PHP-DB] Re: php-db foreign key

2011-08-09 Thread Chris Stinemetz
On Tue, Aug 9, 2011 at 2:55 PM, Frank Flynn fr...@declan.com wrote:

 You already have a foreign key, that is stores.store_by references
users.user_id.  You might not have declared it (which is OK) but if that is
the key you want that is fine.
 I suspect you are seeing an inadvertent Cartesian product.  The way you
have written this query you will get one row from the stores table for each
row in the users table where a store_by = user_id - and because you said
LEFT JOIN you will get one row from the stores table even if there are no
matching rows in the users table.
 So you say you get 3 x the rows you're expecting; are there 3 users that
match that store_by?


No there is only 1 user that match the sotre_by. If the query is not written
correctly do you mind trying to show me how to correctly right it?

When I dump the query and run it in console I get the results I want. Not
sure what I am doing wrong.

mysql SELECT stores.store_subject, stores.store_comments,
stores.store_date, stores.store_tptest, stores.store_by, user
s.user_id, users.user_name, users.first_name, users.last_name FROM stores
LEFT JOIN users ON stores.store_by = users.use
r_id WHERE stores.store_subject = 'Bella Roe 4980 Roe Blvd' ORDER BY
stores.store_date DESC ;
+-++-+-+--+-+---
-++---+
| store_subject   | store_comments | store_date  |
store_tptest| store_by | user_id | user_name
| first_name | last_name |
+-++-+-+--+-+---
-++---+
| Bella Roe 4980 Roe Blvd | test   | 2011-08-09 14:08:05 |
600kbps-3.8mbps |1 |   1 | chrisstinemetz
| Chris  | Stinemetz |
| Bella Roe 4980 Roe Blvd | test1  | 2011-08-09 14:07:49 | 0-250kbps
  |1 |   1 | chrisstinemetz
| Chris  | Stinemetz |
+-++-+-+--+-+---
-++---+
2 rows in set (0.00 sec)


Re: [PHP-DB] Re: php-db foreign key

2011-08-09 Thread Chris Stinemetz

 Your php code had more than one query running (one inside the other).
 It's the outer query that runs twice, not the inner one returning
 double the results



Thanks Peter,

Do you have any suggestions on how to fix this?

Thank you,

Chris

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



Re: [PHP-DB] Re: php-db foreign key

2011-08-09 Thread Chris Stinemetz

 Yes, debug your code and figure out why it's looping twice instead.
 For instance, try the other query in the mysql console.


Thank you! It was the first query. I put a LIMIT 1 on it and now it is
working correctly. I appreciate your help!

Thank you,

Chris

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



[PHP-DB] Left Join

2011-08-07 Thread Chris Stinemetz
I am tyring to build a query that will take the most recent
stores.store_date column then join it with store_list.store_name where
store_list.store_name and
stores.store_subject match then return the most recent stores.store_date.
I am guessing this will require some sort of join. I have been tyring to
figure it
out but have had no luck.
Any help is greatly apprciated.
Thank you.

mysql select * from stores;
+--+-++-+---+--+-+--
---+
| store_id | store_subject   | store_type | store_date  | store_mar
| store_by | store_tptest| store_comment
s  |
+--+-++-+---+--+-+--
---+
|   78 | Bella Roe   | corporate  | 2011-06-28 15:01:02 | 0
|1 | |
  |
|   79 | Bella   | corporate  | 2011-08-06 08:48:26 | 0
|1 | 600kbps-3.8mbps | test
  |
|   80 | Brittney~2120   | corporate  | 2011-08-06 08:48:50 | 1
|1 | 600kbps-3.8mbps | should post t
o Wichita! |
|   81 | Motor   | premier| 2011-08-06 14:52:55 | 1
|1 | 600kbps-3.8mbps | test
  |
|   82 | Liberty | corporate  | 2011-08-06 14:54:41 | 0
|1 | 0-250kbps   | test
  |
|   83 | Seneca~3165 | corporate  | 2011-08-06 14:58:47 | 0
|1 | 600kbps-3.8mbps | test
  |
|   84 | Liberty | corporate  | 2011-08-06 14:59:32 | 0
|1 | 400-600kbps | test
  |
|   85 | Brittney~2120   | corporate  | 2011-08-06 15:00:43 | 0
|1 | 600kbps-3.8mbps | test
  |
|   86 | Liberty | corporate  | 2011-08-06 15:01:11 | 0
|1 | 300-400kbps | test
  |
|   87 | Brittney~2120   | corporate  | 2011-08-06 15:11:06 | 0
|1 | 250-300kbps | test
  |
|   88 | Brittney~2120   | corporate  | 2011-08-06 15:23:53 | 1
|1 | 600kbps-3.8mbps | test
  |
|   89 | Bella   | corporate  | 2011-08-06 15:31:49 | 0
|1 | 600kbps-3.8mbps | test
  |
|   90 | Cleartalk~10221 | premier| 2011-08-06 15:32:54 | 0
|1 | 250-300kbps | test
  |
|   91 | Chit| premier| 2011-08-06 15:33:50 | 1
|1 | 250-300kbps | test
  |
|   92 | || 2011-08-06 15:34:21 | 2
|1 | 300-400kbps | test
  |
|   93 | Bella   | corporate  | 2011-08-07 11:26:13 | 0
|1 | 600kbps-3.8mbps | test
  |
+--+-++-+---+--+-+--
---+
16 rows in set (0.00 sec)
mysql

mysql select * from store_list LIMIT 15;'
++---+++-+---+
| id | market_prefix | store_name | store_type |
market_name | id_market |
++---+++-+---+
|  1 | MCI   | Bella Roe~4980 Roe Blvd| Corporate  |
Kansas City | 0 |
|  2 | MCI   | Cleartalk~4635 Shawnee Dr  | Premier|
Kansas City | 0 |
|  3 | MCI   | Cleartalk~3612 State Avenue| Premier|
Kansas City | 0 |
|  4 | MCI   | Endless Wireless~1620 Central Avenue   | Premier|
Kansas City | 0 |
|  5 | MCI   | Get Wireless~840 Minnesota | Premier|
Kansas City | 0 |
|  6 | MCI   | Ring Ring Wireless~7559 State Avenue   | Premier|
Kansas City | 0 |
|  7 | MCI   | Cleartalk~1212 Sante Fe| Premier|
Kansas City | 0 |
|  8 | MCI   | Cleartalk~10221 W 75th Street  | Premier|
Kansas City | 0 |
|  9 | MCI   | Free Talk~10830 Shawnee Mission Pkwy   | Premier|
Kansas City | 0 |
| 10 | MCI   | Loma Vista~8712 Blue Ridge Blvd| Corporate  |
Kansas City | 0 |
| 11 | MCI   | Ring Ring Wireless~25 W. 39th Street   | Premier|
Kansas City | 0 |
| 12 | MCI   | Ring Ring Wireless~3039 Prospect Ave   | Premier|
Kansas City | 0 |
| 13 | MCI   | Ring Ring Wireless~1201 E Linwood Blvd | Premier|
Kansas City | 0 |
| 14 | MCI   | Ring Ring Wireless~4314 Rainbow Blvd   | Premier|
Kansas City | 0 |
| 15 | MCI   | Ring Ring Wireless~7445 Prospect Ave.  | Premier|
Kansas City | 0 |
++---+++-+---+
15 rows in set (0.00 sec)


Re: [PHP-DB] Left Join

2011-08-07 Thread Chris Stinemetz
On Sun, Aug 7, 2011 at 3:00 PM, Peter Lind peter.e.l...@gmail.com wrote:

 Maybe it's just me, but I can't see anything that would work as

foreign key for you to join on - neither table seems to have a foreign
 key


 Sorry for my ignorance. How do I create the foreign key? The two columns
from each table that have a similar relationship are stores.store_mar and
store_list.id_market. Once the foreign key is build what would be the
correct syntax to achieve my query?

Thank you very much,

  Chris






[PHP-DB] Insert query error

2011-08-05 Thread Chris Stinemetz
I am getting the following error trying to run the below query. Any
suggestions on what I am doing wrong?

Thank you,

Something went wrong while inserting your store visitCannot add or
update a child row: a foreign key constraint fails (`store`.`posts`,
CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`post_store`) REFERENCES
`stores` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE)

$sql = INSERT INTO
posts(market, type, post_store, post_tptest, post_content, post_by, post_date)
VALUES(' . mysql_real_escape_string($_POST['market']) . ',
' . mysql_real_escape_string($_POST['type']) . ',
' . mysql_real_escape_string($_POST['post_store']) . ',   

' . sha1($_POST['post_tptest']) . ',
' . mysql_real_escape_string($_POST['post_content']) . ',
  . $_SESSION['user_id'] . ,
 NOW());

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



[PHP-DB] cascading select

2011-07-14 Thread Chris Stinemetz
I am trying to create a cascading seletct with 3 menu choices.
For some reason my third select menu is not populating. It does not
seem like my ajax is correctly sending $_post values to the final
query in my PHP class I built.
By the time I make it to the final (third) select menu there are no choices.

Hopefully someone can find something I missed in the following code snippits.

Any help is greatly appreciated.

Please excuse the incorrect indentions. For some reason gmail changes it.

Thanks,

Chris

ajax code...

   script
   $(document).ready(function(){
   $(select#type).attr(disabled,disabled);
   $(select#store).attr(disabled,disabled);
   $(select#market).change(function(){
   $(select#type).attr(disabled,disabled);
   $(select#type).html(optionplease wait.../option);
   var id = $(select#market option:selected).attr('value');
   $.post(select_type.php, {id:id}, function(data){
   $(select#type).removeAttr(disabled);
   $(select#type).html(data);
   });
   });

   $(select#type).change(function(){
   $(select#store).attr(disabled,disabled);
   $(select#store).html(optionplease
wait.../option);
   var id = $(select#type option:selected).attr('value');
   $.post(select_store.php, {id:id}, function(data){
   $(select#store).removeAttr(disabled);
   $(select#store).html(data);
   });
   });




   $(form#select_form).submit(function(){
   var market = $(select#market option:selected).attr('value');
   var type = $(select#type option:selected).attr('value');
   var store = $(select#store
option:selected).attr('value');
   if(market0  type0  store0)
   {
   var market = $(select#market option:selected).html();
   var type = $(select#type
option:selected).html();
   var store = $(select#store
option:selected).html();
   $(#result).html('your choices were: '+market +' ,
'+type +' and '+store);
   }
   else
   {
   $(#result).html(you must choose three options!);
   }
   return false;
   });
   });
   /script


php class for populating select menus

?php
class SelectList
{
   protected $conn;
   public function __construct()
   {
   $this-DbConnect();
   }
   protected function DbConnect()
   {
   include db_config.php;
   $this-conn =
mysql_connect($host,$user,$password) OR die(Unable to connect to the
database);
   mysql_select_db($db,$this-conn) OR die(can
not select the database $db);
   return TRUE;
   }
   public function ShowMarket()
   {
   $sql = SELECT DISTINCT id_markets FROM store_list;
   $res = mysql_query($sql,$this-conn);
   $market = 'option value=0market.../option';
   while($row = mysql_fetch_array($res))
   {
   $market .= 'option value=' .
$row['id'] . '' . $row['id_markets'] . '/option';
   }
   return $market;
   }

   public function ShowType()
   {
   $sql = SELECT DISTINCT store_type FROM store_list;
   $res = mysql_query($sql,$this-conn);
   $type = 'option value=0store type.../option';
   while($row = mysql_fetch_array($res))
   {
   $type .= 'option value=' . $row['id']
. '' . $row['store_type'] . '/option';
   }
   return $type;
   }

   public function ShowStore()
   {
   $sql = SELECT store_name FROM store_list WHERE
id_markets=$_POST[id] AND store_type=$_POST[id];
   $res = mysql_query($sql,$this-conn);
   $Store = 'option value=0stores.../option';
   while($row = mysql_fetch_array($res))
   {
   $Store .= 'option value=' .
$row['id'] . '' . $row['store_name'] . '/option';
   }
   return $Store;
   }
}

$opt = new SelectList();

?

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



Re: [PHP-DB] Re: radio form submission

2011-06-24 Thread Chris Stinemetz
Thanks everyone.

 If there is no purpose, I would make the values of the inputs the values you
 want to store in your database.
 Muuch easier..


So I am trying to keep this simple and just assign the value with the
radio button and then insert it into mysql database, but with the
following code I am getting the mysql error: Unknown column '250kbps'
in 'field list' when I choose the first radio button.

I think it has to do with the value being a string, but I haven't been
able to figure out the fix.

Thanks everyone for your help in accomplishing one thing with many
differnt techniques. It is greatly appreciated.

Chris

 Form 

echo 'form method=post action=
Store name: input type=text 
name=store_subject /br /br /
Market:';

echo 'select name=store_mar';
while($row = mysql_fetch_assoc($result))
{
echo 'option value=' . 
$row['mar_id'] . '' .
$row['mar_name'] . '/option';
}
echo '/selectbr /br /';   

echo 'Broadband speed test results: br /br /
0-250kbpsinput type=radio 
name=post_tptest value=0-250kbps /|
250-300kbpsinput type=radio 
name=post_tptest value=250-300kbps /|
300-400kbpsinput type=radio 
name=post_tptest value=300-400kbps /|
400-600kbpsinput type=radio 
name=post_tptest value=400-600kbps /|
600kbps-3.8mbpsinput type=radio 
name=post_tptest
value=600kbps-3.8mbps /br /br /
Store visit details: br /br /
textarea name=post_content 
//textareabr /br /
input type=submit value=Add a store 
visit /
 /form';
}
}
}


 Insert Code 

$sql = INSERT INTO
posts(post_content, 

  post_date,
  post_tptest,
  post_store,
  post_by)
VALUES
(' . 
mysql_real_escape_string($_POST['post_content']) . ',
  NOW(),
   . 
$_POST['post_tptest'] . ,
   . $storeid 
. ,
   . 
$_SESSION['user_id'] . 
);
$result = mysql_query($sql);

if(!$result)
{
//something went wrong, display the 
error
echo 'An error occured while inserting 
your post. Please try
again later.br /br /' . mysql_error();
$sql = ROLLBACK;;
$result = mysql_query($sql);
}
else
{
$sql = COMMIT;;
$result = mysql_query($sql);

//after a lot of work, the query 
succeeded!
echo 'You have succesfully created a 
href=store.php?id='.
$storeid . 'your new store visit/a.';
}
}
}
}
}

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



[PHP-DB] radio form submission

2011-06-23 Thread Chris Stinemetz
So far I am good on creating the form and  submitting it to mysql
database and calling the submitting value from a different script.

My question is: How can I make it so when a user selects radio option
value 1 it will then be displayed as 0-250kbps when I call it the
value in the bottom script?

forgive my indention. Gmail messes it up.


 My Form 


echo 'form method=post action=
Store name: input type=text 
name=store_subject /br /br /
Market:';

echo 'select name=store_mar';
while($row = mysql_fetch_assoc($result))
{
echo 'option value=' . 
$row['mar_id'] . '' .
$row['mar_name'] . '/option';
}
echo '/selectbr /br /';   

echo 'Broadband speed test results: br /br /
0-250kbpsinput type=radio 
name=post_tptest value=1 /|
250-300kbpsinput type=radio 
name=post_tptest value=2 /|
300-400kbpsinput type=radio 
name=post_tptest value=3 /|
400-600kbpsinput type=radio 
name=post_tptest value=4 /|
600kbps-3.8mbpsinput type=radio 
name=post_tptest value=5
/br /br /
Store visit details: br /br /
textarea name=post_content 
//textareabr /br /
input type=submit value=Add a store 
visit /
 /form';

 My display script 

$posts_sql = SELECT
posts.post_store,
posts.post_content,
posts.post_tptest,
posts.post_date,
posts.post_by,
users.user_id,
users.user_name,
users.first_name,
users.last_name
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_store =  . 
mysql_real_escape_string($_GET['id']) . 
ORDER BY
posts.post_date DESC ; 


$posts_result = mysql_query($posts_sql);

if(!$posts_result)
{
echo 'trtdThe posts could not be displayed, 
please try again
later./tr/td/table';
}
else
{

while($posts_row = 
mysql_fetch_assoc($posts_result))
{
echo 'tr class=topic-post
td class=user-post' 
. $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . 'br/' . date('m-d-Y h:iA',
strtotime($posts_row['post_date'])) . '/td
td 
class=post-content' . $posts_row['post_tptest'] .
'br/' . htmlentities(stripslashes($posts_row['post_content'])) .
'/td
  /tr';
}
}

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



Re: [PHP-DB] radio form submission

2011-06-23 Thread Chris Stinemetz
On Thu, Jun 23, 2011 at 2:49 PM, Daniel P. Brown
daniel.br...@parasane.net wrote:
 On Thu, Jun 23, 2011 at 15:46, Chris Stinemetz chrisstinem...@gmail.com 
 wrote:

    Use an if or a switch.  For example:


 I think your suggestions are exactly what I am looking for. I am not
 sure exactly where to place it. Do I insert it after the query
 statment?

    During your while() loop.  This line here:

        td class=post-content' . $posts_row['post_tptest'] .

    If you convert it to a function as Karl suggested, you could do
 something like this:

        td class=post-content' . getSpeed($posts_row['post_tptest']) .


I must be missing something. I am just getting a blank page. Your help
is greatly apprecieated.

The function and query statement is:

function getSpeed($val) {
if($val != 'undefined') {
switch ($val){
   case 1:
$post_tptest = 0-250kbps;
break;
   case 2:
$post_tptest = 250-300kbps;
break;
   case 3:
$post_tptest = 300-400kbps;
break;
   case 4:
$post_tptest = 400-600kbps;
break;
   case 5:
$post_tptest = 600kbps-3.8mbps;
break;
   default:
$post_tptest = Speed Undetected; // or 0-250kbps
break;
   }
} else {
   return(Error, no speed value set);
}
}
}

$post_speed = getSpeed($post_tptest);

//fetch the posts from the database
$posts_sql = SELECT
posts.post_store,
posts.post_content,
posts.post_speed,   

posts.post_date,
posts.post_by,
users.user_id,
users.user_name,
users.first_name,
users.last_name
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_store =  . 
mysql_real_escape_string($_GET['id']) . 
ORDER BY
posts.post_date DESC ; 



The call:

while($posts_row = 
mysql_fetch_assoc($posts_result))
{
echo 'tr class=topic-post
td class=user-post' 
. $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . 'br/' . date('m-d-Y h:iA',
strtotime($posts_row['post_date'])) . '/td
td 
class=post-content' .
getSpeed($posts_row['post_tptest']) . 'br/' .
htmlentities(stripslashes($posts_row['post_content'])) . '/td
  /tr';
}
}


Thank you!

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



Re: [PHP-DB] radio form submission

2011-06-23 Thread Chris Stinemetz

    Use an if or a switch.  For example:


I think your suggestions are exactly what I am looking for. I am not
sure exactly where to place it. Do I insert it after the query
statment?

Thank you,

Chris

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



[PHP-DB] ORDER BY DESC

2011-06-20 Thread Chris Stinemetz
I have the bellow sql query. What is the correct way to add ORDER BY
posts.post_date DESC

I would like to add it to the end of my query, but I am just getting a
blank page or my added query doesn't work echo:

The posts could not be displayed, please try again later.

The query is:

//fetch the posts from the database
$posts_sql = SELECT
posts.post_store,
posts.post_content,
posts.post_date,
posts.post_by,
users.user_id,
users.user_name
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_store =  . 
mysql_real_escape_string($_GET['id']);   



Thank you in advance for your help.

Chris

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



Re: [PHP-DB] ORDER BY DESC

2011-06-20 Thread Chris Stinemetz
On Mon, Jun 20, 2011 at 3:49 PM, Karl DeSaulniers k...@designdrumm.com wrote:
 Try..

 $posts_sql = SELECT posts.post_store, posts.post_content, posts.post_date,
 posts.post_by, users.user_id, users.user_name FROM posts LEFT JOIN users ON
 osts.post_by = users.user_id WHERE posts.post_store = 
 .mysql_real_escape_string($_GET['id']). ORDER BY posts.post_date DESC;


Got it working thanks everyone who responded.

Working query:

$posts_sql = SELECT
posts.post_store,
posts.post_content,
posts.post_date,
posts.post_by,
users.user_id,
users.user_name
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_store =  . 
mysql_real_escape_string($_GET['id']) . 
ORDER BY
posts.post_date DESC ;

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



[PHP-DB] delete message function

2011-06-13 Thread Chris Stinemetz
I created the below delete function, but it doesn't seem to be working
correctly. When I enter the correct password it get my echo Incorrect
Password Did not Delete! When I leave the password blank the message
will delete from mysql table.

Am I missing something??

Thanks in advance,

Chris

function delete_message($msg) {
extract($msg, EXTR_PREFIX_ALL, 'row');
$result = mysql_query(SELECT ID FROM mbmsgs WHERE Parent = $row_ID;);

while ($row = mysql_fetch_array($result)) {
delete_message($row);
}
mysql_query(DELETE FROM mbmsgs WHERE ID = $row_ID;);
}

$result = mysql_query(SELECT Title, Password FROM mbmsgs WHERE ID
= {$_REQUEST['Msg']};);
if (!$result) exit;
if (!mysql_num_rows($result)) exit;
extract(mysql_fetch_array($result), EXTR_PREFIX_ALL, 'msg');

if (isset($_POST['Password'])) {
if (sha1($_POST['Password']) != $msg_Password) {
echo Incorrect password did not delete!;
exit;

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



[PHP-DB] Re: delete message function

2011-06-13 Thread Chris Stinemetz
On Tue, Jun 14, 2011 at 12:31 AM, Chris Stinemetz
chrisstinem...@gmail.com wrote:
 I created the below delete function, but it doesn't seem to be working
 correctly. When I enter the correct password it get my echo Incorrect
 Password Did not Delete! When I leave the password blank the message
 will delete from mysql table.

 Am I missing something??

 Thanks in advance,

 Chris

Sorry. I left out the call to the function. Below is the whole snippit
for the function and call.

function delete_message($msg) {
extract($msg, EXTR_PREFIX_ALL, 'row');
$result = mysql_query(SELECT ID FROM mbmsgs WHERE Parent = $row_ID;);

while ($row = mysql_fetch_array($result)) {
delete_message($row);
}
mysql_query(DELETE FROM mbmsgs WHERE ID = $row_ID;);
}

$result = mysql_query(SELECT Title, Password FROM mbmsgs WHERE ID
= {$_REQUEST['Msg']};);
if (!$result) exit;
if (!mysql_num_rows($result)) exit;
extract(mysql_fetch_array($result), EXTR_PREFIX_ALL, 'msg');

if (isset($_POST['Password'])) {
if (sha1($_POST['Password']) != $msg_Password) {
echo Incorrect password did not delete!;
exit;
}
$result = mysql_query(SELECT ID FROM mbmsgs WHERE Parent =
{$_POST['Msg']};);

while ($row = mysql_fetch_array($result)) {
delete_message($row);
}

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



[PHP-DB] mysql_query

2011-06-06 Thread Chris Stinemetz
Hello all,

Not sure what I am doing wrong.

I have a simple form that populate the variables in a mysql query. I
know the selected values are making it to the form porcessing script
because I can echo them on the processing script as indicated below.

You Selected Cell_Sect = 1_1
You Selected Date = 03/10/11 18:15
You Selected Market = MCI

For some reason the above is all I am getting when I submit my form.

I beleive it has somthing to do with my results query below.

$result = mysql_query(select * FROM evdo WHERE Market like '%$term'
and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10);

Beow is my whole script for processing the form in case it maybe something else.

Thanks,

Chris


!doctype html public -//w3c//dtd html 3.2//en

html
?php

// database access parameters
$dbservertype='mysql';
$servername= left out for privacy;
// username and password to log onto db server
$dbusername='';
$dbpassword='';
// name of database
$dbname='pcmd';

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ($servername,$dbuser,$dbpassword);
if(!$link){
die('Could not conect: ' . mysql_error());
}
echo 'YOU ARE CONNECTED TO PCMD DATABASE';

mysql_select_db($dbname,$link) or die (could not open db.mysql_error());
}
 End of connecting to database 
?
!!DOCTYPE HTML PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1-transitional.dtd'
head
titleDemo Multiple drop down list box for PCMD data/title
style type=text/css 
  TABLE {
 border: 1px solid #98bf21;
 border-collapse:collapse;
  }

  TH {
 border: 1px solid #98bf21;
 padding-bottom: 4px;
 padding-left: 7px:
 padding-right: 7px;
 padding-top: 5px;
 font-size: 1.2em;
 background-color:limegreen;
 color: white;
 text-align: left;
  }

  TD {
 border: 1px solid #98bf21;
 padding-bottom: 2px;
 padding-left: 7px:
 padding-right: 7px;
 padding-top: 3px;
 font-size: 1.0em;
  }

  TR.alt TD {
  background-color: #eaf2d3;

  }

/style
meta name=GENERATOR content=Arachnophilia 4.0
meta name=FORMATTER content=Arachnophilia 4.0
/head

body
?php
$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$term=$_POST['term'];

$result = mysql_query(select * FROM evdo WHERE Market like '%$term'
and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10);


$firstRow=1;
$rowNum = 0;
echo table;
while($row = mysql_fetch_assoc($result)) {
   if($firstRow == 1) {
  echo tr;

  foreach($row as $key = $value) {
  echo th . $key . /th;
  }
  echo /trtr;
  $firstRow=0;
  $rowNum++;
   }
   else {
  if(  ($rowNum++ % 2) == 1) {
 echo tr class=\alt\;
  } else {
 echo tr;
  }
   }
   foreach($row as $key = $value ) {
   echo td . $value . /td  ;
   }
   echo /tr;
}
echo /table;

echo You Selected Cell_Sect = $cat brYou Selected Date =
$subcatbrYou Selected Market = $term;


?

/body

/html

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



[PHP-DB] Event Calendar tutorial

2011-05-31 Thread Chris Stinemetz
Hello all,

I am curious if anyone knows of a good tutorial to build an event calendar?

Thank you,

Chris

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



[PHP-DB] PHP Delete confirmation

2011-04-28 Thread Chris Stinemetz
I have been trying to figure out how to add delete confirmation for
the bellow snippet of code. I would prefer not to use javascript. Can
anyone offer any advise on how to right the delete confirmation in
PHP?

Thank you in advance.

P.S. I apologize for the indention. For some reason gmail messes it up.

?php
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {

// echo out the contents of each row into a table
echo tr;
echo 'td' . $row['Name'] . '/td';
echo 'td' . $row['Date'] . '/td';   

echo 'td' . $row['StoreInfo'] . '/td';
echo 'td' . $row['Address'] . '/td';
echo 'td' . $row['Type'] . '/td';
echo 'td' . $row['EngTech'] . '/td';
echo 'td' . $row['StoreManager'] . '/td';
echo 'td' . $row['BBtime'] . '/td';
echo 'td' . $row['BBup'] . '/td';
echo 'td' . $row['BBdown'] . '/td';
echo 'td' . $row['SiteSect'] . '/td';
echo 'td' . $row['VoiceCall'] . '/td';
echo 'td' . $row['Comments'] . '/td';
echo 'tda href=edit.php?id=' . $row['id']
.'Edit/a/td';
echo 'tda href=delete.php?id=' . $row['id']
.'Delete/a/td';
echo /tr;
}

// close table
echo /table;
?

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



[PHP-DB] automactic email notification

2011-04-13 Thread Chris Stinemetz
I have an all-in-one form which allows record edits, adds and deletes
in a mysql table.

I would like to add the ability to automatically send email update to
a distribution list whenever a record is edited, deleted, or added.

I won't be hosting my own mail server so instead I will be using remote SMTP.

The mail script I created works just fine I am just not sure how to
put this all together for the notifications when the table is altered.

Thank you in advance!

Mail Script:

?php
 require_once Mail.php;

 $from = Someone email@.com;
 $to = Someone Recipient email@.com;
 $subject = Hi!;
 $body = Hi,\n\nHow are you?;

 $host = example.com;
 $port = 587;
 $username = example;
 $password = example;

 $headers = array ('From' = $from,
   'To' = $to,
   'Subject' = $subject);
 $smtp = Mail::factory('smtp',
   array ('host' = $host,
 'port' = $port,
 'auth' = true,
 'username' = $username,
 'password' = $password));

 $mail = $smtp-send($to, $headers, $body);

 if (PEAR::isError($mail)) {
   echo(p . $mail-getMessage() . /p);
  } else {
   echo(pMessage successfully sent!/p);
  }
 ?



Form Script:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd;
html
head
titleATC West Swap/title
script type='text/javascript' src='../js/jquery-1.2.3.js'/script
script type='text/javascript' src='../js/menu.js'/script

link rel=stylesheet href=../css/style.css type=text/css media=screen /


/style
/head
body
div id=boundary
h1West RF Engineering Dashboard/h1
ul id=nav
lia href=../index.phpHome/a/li
lia href=#ATC West Swap/a
  ul
lia href=atcswap.phpExpiring Leases/a/li
lia href=lowmou.phpLow MOU/a/li
  /ul
/li
/ul
div id=content

/div
p id=footerLow MOU WEST/p
HR
?
$objConnect = mysql_connect(localhost,cstine,cstine) or
die(mysql_error());
$objDB = mysql_select_db(atc);

//*** Add Condition ***//
if($_POST[hdnCmd] == Add)
{
$strSQL = INSERT INTO lowmou ;
$strSQL .=(SiteID,NewSiterraSiteID,ATCSiteID,CricketRegion,Comments,
Progress,willsitebedecom,relocationTowerVendor) 
;
$strSQL .=VALUES ;
$strSQL 
.=('.$_POST[txtAddSiteID].','.$_POST[txtAddNewSiterraSiteID].'
;
$strSQL .=,'.$_POST[txtAddATCSiteID].' ;
$strSQL 
.=,'.$_POST[txtAddCricketRegion].','.$_POST[txtAddComments].'
;
$strSQL .=,'.$_POST[txtAddProgress].' ;
$strSQL 
.=,'.$_POST[txtAddwillsitebedecom].','.$_POST[txtAddrelocationTowerVendor].')
;
$objQuery = mysql_query($strSQL);

if(!$objQuery)
{
echo Error Save [.mysql_error().];
}
//header(location:$_SERVER[PHP_SELF]);
//exit();
}

//*** Update Condition ***//
if($_POST[hdnCmd] == Update)
{
$strSQL = UPDATE lowmou SET ;
$strSQL .=SiteID = '.$_POST[txtEditSiteID].' ;
$strSQL .=,NewSiterraSiteID = '.$_POST[txtEditNewSiterraSiteID].' 
;
$strSQL .=,ATCSiteID = '.$_POST[txtEditATCSiteID].' ;
$strSQL .=,CricketRegion = '.$_POST[txtEditCricketRegion].' ;
$strSQL .=,Comments = '.$_POST[txtEditComments].' ;
$strSQL .=,Progress = '.$_POST[txtEditProgress].' ;
$strSQL .=,willsitebedecom = '.$_POST[txtEditwillsitebedecom].' ; 
$strSQL .=,relocationTowerVendor =
'.$_POST[txtEditrelocationTowerVendor].' ;
$strSQL .=WHERE SiteID = '.$_POST[hdnEditSiteID].' ;
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo Error Update [.mysql_error().];
}
//header(location:$_SERVER[PHP_SELF]);
//exit();
}

//*** Delete Condition ***//
if($_GET[Action] == Del)
{
$strSQL = DELETE FROM lowmou ;
$strSQL .=WHERE SiteID = '.$_GET[srID].' ;
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo Error Delete [.mysql_error().];
}
//header(location:$_SERVER[PHP_SELF]);
//exit();
}

$strSQL = SELECT * FROM lowmou;
$objQuery = mysql_query($strSQL) or die (Error Query [.$strSQL.]);
?
form name=frmMain method=post action=?=$_SERVER[PHP_SELF];?
input type=hidden name=hdnCmd value=
table
  tr
thSiteID /th
thNewSiterraSiteID /th
thATCSiteID /th
thCricketRegion /th
thComments /th
thProgress/th
thWill site be decom?/th
thRelocation Tower Vendor/th
thEdit /th
thDelete /th
  /tr

?
while($objResult = mysql_fetch_array($objQuery))
{
?

  ?
if($objResult[SiteID] == $_GET[srID] and $_GET[Action] == Edit)
{
  ?
  tr
tddiv align=center
input type=text name=txtEditSiteID size=5
value=?=$objResult[SiteID];?
input type=hidden name=hdnEditSiteID size=5
value=?=$objResult[SiteID];?
/div/td
tdinput type=text name=txtEditNewSiterraSiteID size=10
value=?=$objResult[NewSiterraSiteID];?/td
tdinput type=text name=txtEditATCSiteID size=10

Re: [PHP-DB] Re: automactic email notification

2011-04-13 Thread Chris Stinemetz
On Wed, Apr 13, 2011 at 11:08 AM, Jim Giner
jim.gi...@albanyhandball.com wrote:
 Without looking at your HUGE code stream, I'm curious what your question
 really is.  If you know how to send an email, and you know how to update
 your table, then isn't your task simply to send an email after updating the
 table?

Yes.

 I would make the email a function to get it out of the way and
 then add a call to it right after I did an update.  The user probably gets a
 message of the successful update, so when you do that, that's when you call
 your email function.  Maybe have a couple of arguments in the function to
 pass some specifics and that's that.


Could you possbily show me an example? I am a newby when it comes to PHP.
Thank you!




 --
 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-DB] error

2011-04-07 Thread Chris Stinemetz
I am getting the following error when I try to use my edit.php script:

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 '' at line 1

I can't seem to find anything wrong with my syntax below.

Has anyone ever had this issue?

I have been googling it for a couple hours now.

Thank you in advance!

Chris

?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
/*
 EDIT.PHP
 Allows user to edit specific entry in database
*/

 // creates the edit record form
 // since this form is used multiple times in this file, I have made
it a function that is easily reusable
 function renderForm($id, $Cricket_Region, $Market, $error)
 {
 ?
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd;
 html
 head
 titleEdit Record/title
 /head
 body
 ?php
 // if there are any errors, display them
 if ($error != '')
 {
 echo 'div style=padding:4px; border:1px solid red;
color:red;'.$error.'/div';
 }
 ?

 form action= method=post
 input type=hidden name=id value=?php echo $id; ?/
 div
 pstrongID:/strong ?php echo $id; ?/p
 strongCricket Region: */strong input type=text name=Cricket
Region value=?php echo $Cricket_Region; ?/br/
 strongMarket: */strong input type=text name=Market
value=?php echo $Market; ?/br/
 p* Required/p
 input type=submit name=submit value=Submit
 /div
 /form
 /body
 /html
 ?php
 }



 // connect to the database
 include('../PHP_Scripts/connect-db.php');


 // check if the form has been submitted. If it has, process the form
and save it to the database
 if (isset($_POST['submit']))
 {
 // confirm that the 'id' value is a valid integer before getting the form data
 if (is_numeric($_POST['id']))
 {
 // get form data, making sure it is valid
 $id = $_POST['id'];
 $Cricket_Region =
mysql_real_escape_string(htmlspecialchars($_POST['Cricket_Region']));
 $Market = mysql_real_escape_string(htmlspecialchars($_POST['Market']));

 // check that firstname/lastname fields are both filled in
 if ($Cricket_Region == '' || $Market == '')
 {
 // generate error message
 $error = 'ERROR: Please fill in all required fields!';

 //error, display form
 renderForm($id, $Cricket_Region, $Market, $error);
 }
 else
 {
 // save the data to the database
 mysql_query(UPDATE expiringleases SET
Cricket_Region='$Cricket_Region', Market='$Market' WHERE id='$id')
 or die(mysql_error());

 // once saved, redirect back to the view page
 header(Location: view.php);
 }
 }
 else
 {
 // if the 'id' isn't valid, display an error
 echo 'Error!';
 }
 }
 else
 // if the form hasn't been submitted, get the data from the db and
display the form
 {

 // get the 'id' value from the URL (if it exists), making sure that
it is valid (checking that it is numeric/larger than 0)
 if (isset($_GET['id']))
 {
 // query db
 $id = $_GET['id'];
 $result = mysql_query(SELECT * FROM expiringleases WHERE id=$id)
 or die(mysql_error());
 $row = mysql_fetch_array($result);

 // check that the 'id' matches up with a row in the databse
 if($row)
 {

 // get data from db
 $Cricket_Region = $row['Cricket_Region'];
 $Market = $row['Market'];

 // show form
 renderForm($id, $Cricket_Region, $Market, '');
 }
 else
 // if no match, display result
 {
 echo No results!;
 }
 }
 else
 // if the 'id' in the URL isn't valid, or if there is no 'id' value,
display an error
 {
 echo 'Error!';
 }
 }
?

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



Re: [PHP-DB] error

2011-04-07 Thread Chris Stinemetz
I am pretty sure it is in my code. I am just getting an error form one
of my echoes. Still can't get it to work correctly though. Any help is
greatly appreciated.

Thank you,

Chris

?php
/*
 EDIT.PHP
 Allows user to edit specific entry in database
*/

 // creates the edit record form
 // since this form is used multiple times in this file, I have made
it a function that is easily reusable
 function renderForm($id, $Cricket_Region, $Market, $error)
 {
 ?
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd;
 html
 head
 titleEdit Record/title
 /head
 body
 ?php
 // if there are any errors, display them
 if ($error != '')
 {
 echo 'div style=padding:4px; border:1px solid red;
color:red;'.$error.'/div';
 }
 ?

 form action= method=post
 input type=hidden name=id value=?php echo $id; ?/
 div
 pstrongID:/strong ?php echo $id; ?/p
 strongFirst Name: */strong input type=text
name=Cricket_Region value=?php echo $Cricket_Region; ?/br/
 strongLast Name: */strong input type=text name=Market
value=?php echo $Market; ?/br/
 p* Required/p
 input type=submit name=submit value=Submit
 /div
 /form
 /body
 /html
 ?php
 }



 // connect to the database
 include('../PHP_Scripts/connect-db.php');

 // check if the form has been submitted. If it has, process the form
and save it to the database
 if (isset($_POST['submit']))
 {
 // confirm that the 'id' value is a valid integer before getting the form data
 if (is_string($_POST['Search_Ring']))
 {
 // get form data, making sure it is valid
 $id = $_POST['Search_Ring'];
 $Cricket_Region =
mysql_real_escape_string(htmlspecialchars($_POST['Cricket_Region']));
 $Market = mysql_real_escape_string(htmlspecialchars($_POST['Market']));

 // check that Cricket_Region/Market fields are both filled in
 if ($Cricket_Region == '' || $Market == '')
 {
 // generate error message
 $error = 'ERROR: Please fill in all required fields!';

 //error, display form
 renderForm($id, $Cricket_Region, $Market, $error);
 }
 else
 {
 // save the data to the database
 mysql_query(UPDATE expiringleases SET
Cricket_Region='$Cricket_Region', Market='$Market' WHERE
Search_Ring='$id')
 or die(mysql_error());

 // once saved, redirect back to the view page
 header(Location: ATC.php);
 }
 }
 else
 {
 // if the 'id' isn't valid, display an error
 echo 'Error!';
 }
 }
 else
 // if the form hasn't been submitted, get the data from the db and
display the form
 {

 // get the 'id' value from the URL (if it exists), making sure that
it is valid (checing that it is numeric/larger than 0)
 if (isset($_GET['Search_Ring']))
 {
 // query db
 $id = $_GET['Search_Ring'];
 $result = mysql_query(SELECT * FROM expiringleases WHERE Search_Ring=$id)
 or die(mysql_error());
 $row = mysql_fetch_array($result);

 // check that the 'id' matches up with a row in the databse
 if($row)
 {

 // get data from db
 $Cricket_Region = $row['Cricket_Region'];
 $Market = $row['Market'];

 // show form
 renderForm($id, $Cricket_Region, $Market, '');
 }
 else
 // if no match, display result
 {
 echo No results!;
 }
 }
 else
 // if the 'id' in the URL isn't valid, or if there is no 'id' value,
display an error
 {
 echo 'Error!';
 }
 }

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



Re: [PHP-DB] Re: jpgraph and mysql passing array

2011-03-27 Thread Chris Stinemetz
On Sat, Mar 26, 2011 at 9:44 PM, Brian Smither bhsmit...@gmail.com wrote:
 Would you try an experiment?

Thanks for for the suggestion but this didn't seem to work. I beleive
it is a header conflict based on what I have researched.
I just can't seem to find a solution.


 In this line:
 $sql = (SELECT * FROM evdobanding WHERE Market like '%$term' and Cell_Sect = 
 '$term2' and Date = '$term3' ORDER BY distance asc);

 Change to:
 $sql = SELECT * FROM evdobanding WHERE Market like '%.$term.' and 
 Cell_Sect = '.$term2.' and Date = '.$term3.' ORDER BY distance asc;

 That is, remove the parenthesis and concatenate the variables into the string.


The code in the PHP block:

  echo TEST DATA PRINT;
  print_r($datay,false);

is passing all the values from the sql query because I can see them on
the page with the jpgraph error.

For example:

TEST DATA PRINTArray ( [0] = 665 [1] = 7093 [2] = 3 [3] =
45816 [4] = 70848 [5] = 41365 [6] = 35676 [7] = 22434 [8] = 5450
[9] = 29131 [10] = 35244 [11] = 48614 [12] = 51748 [13] = 55497
[14] = 79042 [15] = 732 [16] = 1375 [17] = 1094 [18] = 897 [19]
= 1122 [20] = 3059 [21] = 5350 [22] = 5080 [23] = 3082 [24] =
2737 [25] = 326 [26] = 1334 [27] = 736 [28] = 469 [29] = 127 [30]
= 105 [31] = 111 [32] = 197 [33] = 208 [34] = 950 [35] = 9 [36]
= 9 [37] = 19 [38] = 8 [39] = 17 [40] = 90 [41] = 1917 [42] =
1289 [43] = 2051 [44] = 1534 [45] = 1 [46] = 2 [47] = 4 [48] = 4
[49] = 7 [50] = 8 [51] = 9 [52] = 18 [53] = 22 [54] = 5 [55] =
3 [56] = 1 [57] = 1 [58] = 2 )

JpGraph ERROR 25121



From the research I have done so far using Jpgraph I have found this
link to a similar issue:

http://ubuntuincident.wordpress.com/tag/jpgraph/

but I am unable to get my arrays from the sql query to populate the graph.

Thank you in advance,

Chris

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



[PHP-DB] jpgraph and mysql passing array

2011-03-23 Thread Chris Stinemetz
Hello,



I hope you can help me. The Jpgraph forum seems to be pretty
uneventful with participation.

I am trying to pass arrays through the image tag to populate my
variables for my graph.

I keep getting an error that there is no input. Do you have any suggestions?

I would greatly appreciate it! I have been trying to figure this out
for several hours.



Below is my code:



I need some help with finding a solution. For some reason my graph is
not showing up when it evident that my arrays are being passed.



When I use:



echo TEST DATA PRINT;

print_r($datay,false);



---



I keep getting the error:

Empty input data array specified for plot.



---



My php script is as follows:

---



!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html xmlns=http://www.w3.org/1999/xhtml;



head

titleKCRF Dashboard/title

?php

ini_set('display_errors', 1);

error_reporting(E_ALL);



$term=$_POST['term'];

$term2=$_POST['term2'];

$term3=$_POST['term3'];



//include ('err_reporting.php');

require ('PHP_Scripts/config.php');

require_once ('jpgraph/jpgraph.php');

require_once ('jpgraph/jpgraph_line.php');



   $sql = (SELECT * FROM evdobanding WHERE Market like '%$term' and
Cell_Sect = '$term2' and Date = '$term3' ORDER BY distance asc);

   $result = mysql_query($sql);



   while($row = mysql_fetch_array($result))

   {

   $datay[] = $row[MBusage];

   $datax[] = $row[Distance];

   }

  echo TEST DATA PRINT;

  print_r($datay,false);

?





style type=text/css

!--



 #navbar ul {

    margin: 0;

    padding: 5px;

    list-style-type: none;

    text-align: center;

    background-color: #000;

    }



#navbar ul li {

    display: inline;

    }



#navbar ul li a {

    text-decoration: none;

    padding: .2em 1em;

    color: #fff;

    background-color: #000;

    }



#navbar ul li a:hover {

    color: #000;

    background-color: #fff;

    }



--

/style



/head



fieldset style=border: 1px ridge limegreen; color: limegreen;
legend style=color: #000; font-family: verdana; font-size:
14pt;EVDO PCMD BANDING/legend body div id=navbar

  ul

    lia href=index.phpHome/a/li

    lia href=dd3.phpEVDO PCMD KPI/a/li

    lia href=banding.phpEVDO Distance Banding/a/li

    lia href=test.phpTEST_BANDING/a/li

    lia href=LinkHere/a/li

  /ul

/div



/fieldset

?php

echo You Selected the following:brMarket = $term brCell_Sector =
$term2brTimestamp = $term3br; ?



img src=bandingGraph.php?$datax=$row[Distance]$datay=$row[MBusage];
// I think this is where I am having issues.





/body

/html

---



My graph script is:



?php // content=text/plain; charset=utf-8

require_once ('jpgraph/jpgraph.php');

require_once ('jpgraph/jpgraph_line.php');



   // Create the graph.

   $graph = new Graph(1024,450,auto);



   $graph-SetScale(textlin);

   $graph-SetShadow();



   // Slightly adjust the legend from it's default position

   $graph-legend-Pos(0.03,0.5,right,center);

   $graph-legend-SetFont(FF_FONT1,FS_BOLD);



   //Setup X-scale

 $graph-xaxis-SetTextTickInterval(10);

 $graph-xaxis-SetTickLabels($datax);

 //$graph-xtick_factor = 1;

    $graph-xaxis-SetLabelAngle(30);



   // Create the linear plot

   $lineplot= new LinePlot($datay);

   $p1 = new LinePlot($datay);

   $p1-mark-SetType(MARK_DIAMOND);

   $p1-mark-SetFillColor(blue);

   $p1-mark-SetWidth(;

   $p1-SetColor(blue);

   $p1-SetCenter();

   $p1-SetLegend(EVDO F1 Carrier);

   $graph-Add($p1);



   // Add the plot to the graph

   $graph-Add($lineplot);



   // Setup margin and titles

   $graph-img-SetMargin(40,40,50,60);

   $graph-title-SetMargin(10);

   $graph-title-Set(Distance in MIles);

   $graph-title-SetFont(FF_VERDANA,FS_BOLD,12);



   // set margin color

   $graph-SetMarginColor('#dcfade');

   // Use built in font

   $graph-title-SetFont(FF_ARIAL,FS_NORMAL,14);

   $graph-ygrid-SetFill(true,'#EFEFEF@0.6','#e5e5e5@0.6');



   $graph-xgrid-Show();

   $graph-SetBackgroundImageMix(15);

   $graph-legend-Pos(0.02,0.03,right,top);

   $graph-legend-SetFont(FF_FONT1,FS_BOLD);







   $graph-xaxis-title-Set(Miles);

   $graph-yaxis-title-Set(MBusage);

   $graph-SetAlphaBlending();



   // Display the graph

   $graph-Stroke();

?





Thank you,



Chris

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