[PHP-DB] User Authentication
Hello,
I could use some help here. I have a script that checks a user name
and password against the MySQL DB. I have it set as a function so I
included/require it on the page. Here is the script:
function login($username, $password)
// check username and password with db
{
// connect to db
$conn = db_connect();
if (!$conn)
return false;
// check if username
$result = ("select user_id password FROM users WHERE
username='$username' AND password=md5('$password')");
if (!$result)
return false;
if (mysql_num_rows($result) > 0 )
return true;
else
return false;
}
Here is my DB script:
function db_connect()
{
// connect to database
$result = mysql_connect("localhost", "xx", "xx");
if (!$result)
return false;
if (!mysql_select_db(""));
return false;
return $result;
}
When I change the "return false" to "return true" in the first script
(login) it authenticates, but logs any one in. Not good. Does anyone
have any ideas or suggestions?
Thanks in advance,
Craig
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] User Authentication
Thanks - I can't believe I missed that. :( Craig __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimbmedia.com _ On Feb 27, 2004, at 8:34 AM, Jason Wong wrote: On Friday 27 February 2004 22:26, Craig Hoffman wrote: I could use some help here. I have a script that checks a user name and password against the MySQL DB. I have it set as a function so I included/require it on the page. Here is the script: [snip] When I change the "return false" to "return true" in the first script (login) it authenticates, but logs any one in. Not good. Does anyone have any ideas or suggestions? You aren't actually performing any queries -- you're missing a mysql_query(). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* The average girl would rather have beauty than brains because she knows that the average man can see much better than he can think. -- Ladies' Home Journal */ -- 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] mysql_num_rows
Perhaps someone could look at this function and help me trouble shoot
it? This function notifies the user of their new passwd.
I keep getting an error message on this page (see below). What's
strange is the script seems to be working because i am getting an
email with my new password. Here is the error message I am receiving:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in
/Users/choffman/Sites/www/cyclistsedge/include/
forgot_password_functions.php on line 70
suggestions? Anything will be helpful. Much Thanks CH
function notify_password($username, $password)
// notify the user that their password has been changed
{
$query ="SELECT username FROM users WHERE username=('$username')";
// $result = mysql_query($query, $db);
if (!$query)
{
return false; // not changed
}
line 70 => else if (mysql_num_rows($query)==1)
$user_id = mysql_result($query, 0, 'user_id');
$from = "From: [EMAIL PROTECTED] \r\n";
$mesg = "Your password has been changed to $password \r\n"
."You might want to change it next time you log in. \r\n";
if (mail($username, 'Cyclists Edge login information', $mesg,
$from))
return true;
else
return false;
}
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_num_rows
ok, I uncommented the line and changed a few things around. However I
am still getting errors. I really do appreciate everyone's help.
Thanks CH
Here is the 'new' code:
function notify_password($username, $password)
// notify the user that their password has been changed
{
$query ="SELECT username FROM users WHERE username=('$username')";
=> line 65 $result = mysql_query($query, $db);
if (!$query)
{
return false; // not changed
}
=> line 70 else if (mysql_num_rows($result)==1)
$user_id = mysql_result($result, 0, 'user_id');
$from = "From: [EMAIL PROTECTED] \r\n";
$mesg = "Your password has been changed to $password \r\n"
."You might want to change it next time you log in. \r\n";
if (mail($username, 'Cyclists Edge login information', $mesg,
$from))
return true;
else
return false;
}
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in
/Users/choffman/Sites/www/cyclistsedge/include/
forgot_password_functions.php on line 65
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in
/Users/choffman/Sites/www/cyclistsedge/include/
forgot_password_functions.php on line 70
Your new password has been sent to your email address.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 3, 2004, at 2:17 PM, Daniel Clark wrote:
$query ="SELECT username FROM users WHERE
username=('$username')";
// $result = mysql_query($query, $db);
Above line should be uncommented.
if (!$query)
And the "if" checking the number of rows returned from the $result set.
--
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
Re: [PHP-DB] mysql_num_rows
I got it working! Thanks everyone!
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 3, 2004, at 2:46 PM, Micah Stevens wrote:
the $db variable isn't referencing a proper connection. As you did not
create
the db connection in this function, I'm assuming it's a scope problem.
Make
sure that $db is global, and then add a global statement to the first
line in
the function for this variable.
the $db you're referencing in the query is not the same $db that you
assigned
the connection parameter to. If you're a sloppy programmer like me,
and you
only have 1 connection, you can eliminate it from the query statement
if you
want.
-Micah
On Wednesday 03 March 2004 12:33 pm, Craig Hoffman wrote:
ok, I uncommented the line and changed a few things around. However I
am still getting errors. I really do appreciate everyone's help.
Thanks CH
Here is the 'new' code:
function notify_password($username, $password)
// notify the user that their password has been changed
{
$query ="SELECT username FROM users WHERE username=('$username')";
=> line 65 $result = mysql_query($query, $db);
if (!$query)
{
return false; // not changed
}
=> line 70 else if (mysql_num_rows($result)==1)
$user_id = mysql_result($result, 0, 'user_id');
$from = "From: [EMAIL PROTECTED] \r\n";
$mesg = "Your password has been changed to $password \r\n"
."You might want to change it next time you log in.
\r\n";
if (mail($username, 'Cyclists Edge login information', $mesg,
$from))
return true;
else
return false;
}
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in
/Users/choffman/Sites/www/cyclistsedge/include/
forgot_password_functions.php on line 65
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in
/Users/choffman/Sites/www/cyclistsedge/include/
forgot_password_functions.php on line 70
Your new password has been sent to your email address.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 3, 2004, at 2:17 PM, Daniel Clark wrote:
$query ="SELECT username FROM users WHERE
username=('$username')";
// $result = mysql_query($query, $db);
Above line should be uncommented.
if (!$query)
And the "if" checking the number of rows returned from the $result
set.
--
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Inserting Data in Multiple Tables - MySQL
Is it possible to write one INSERT statement to populate multiple tables? __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Inserting Data in Multiple Tables.. again
Here is the problem I am experiencing: I have a form that collects data and I would like it to send it to three tables in a MySQL DB. One table is called TRAININGLOG , other is called CORE and the third is USERS. The USER table is the main table that contains the primary key. My question is, what is the correct way for handling something like this? Do I need to write three separate queries (INSERT) statements? I am using MySQL 4.0.17 if that helps? Thanks in advance, Craig __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Sessions, Cookies and other
Hi there, I have a script where the administrator of the site can add / edit / delete records. Here's how its works: basically the admin selects a user from a drop down menu and hits submit. This goes to a page where it queries the DB and returns some basic info - name, email address and so on. For example: You selected Jim Shoe - his email address is [EMAIL PROTECTED] The problem I am having is when the user returns to this "hub" page from editing a record or adding record it comes back blank. How can I get to show the information again? Are sessions and cookies the answer? Any insight on how to do this is appreciated. Thanks Craig ______ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] tick mark `
Why is it when I have this ` tick mark in my query it works fine, but
when I remove them it I get an error?
Error: 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 'interval, heartrate, morning_hr, hr_for_intervals, watts, rpms,
Here is my query:
$query = "INSERT INTO traininglog ( `user_id` , `power_level` ,
`weight` , `comments` , `workout` , `distance` , `time` , `interval` ,
`heartrate` , `morning_hr` , `hr_for_intervals` , `watts` , `rpms` ,
`date` , `time_upload` , `week_of` , `sleep` , `motivation` ,
`workout_name` , `rpe` , `candence` , `crunchs` , `leg_raises` ,
`situp_with_twist` , `superman` , `situps` , `russian_twist` ,
`back_extensions` , `situp_crunchs` , `side_crunchs` ,
`balance_bicycles` , `v_ups` , `leg_rotation` , `medicine_ball_throw` ,
`pull_ups` , `push_ups` , `climbing` ) VALUES ($_POST[user_id],
'$_POST[power_level]', $_POST[weight], '$_POST[comments]',
'$_POST[workout]', '$_POST[distance]', '$_POST[time]' '.'
'$_POST[interval]', $_POST[heartrate], $_POST[morning_hr],
$_POST[hr_for_intervals], $_POST[watts], $_POST[rpms], $_POST[date],
NOW('$_POST[time_upload]') '.'
'$_POST[week_of]', $_POST[sleep], '$_POST[motivation]',
'$_POST[workout_name]', $_POST[rpe], $_POST[candence], $_POST[crunchs],
$_POST[leg_raises], $_POST[situp_with_twist] '.'
$_POST[superman], $_POST[situps], $_POST[russian_twist],
$_POST[back_extensions], $_POST[situp_crunchs], $_POST[side_crunchs],
$_POST[balance_bicycles], $_POST[v_ups] '.'
'$_POST[leg_rotation]', $_POST[medicine_ball_throw], $_POST[pull_ups],
$_POST[push_ups], '$_POST[climbing]'
)";__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] DATE_SUB Issues
Hi There,
Perhaps someone could lend me a hand here on this query. I have a
query where I would like it to SUM up the last 7 days of records
further, It needs to start a new week on Monday. The 'time_upload'
field is a datetime field. What am I doing wrong or not doing here ?
SELECT SUM(distance), DATE_FORMAT('time_upload', '%u'),
WEEK('time_upload', '7') FROM TRAININGLOG WHERE DATE_SUB(NOW(),INTERVAL
7 DAY )
< =time_upload
Thanks,
Craig H.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DATE_SUB Issues
still no luck - any other suggestions?
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Mar 29, 2004, at 8:18 AM, John W. Holmes wrote:
From: "Craig Hoffman" <[EMAIL PROTECTED]>
Perhaps someone could lend me a hand here on this query. I have a
query where I would like it to SUM up the last 7 days of records
further, It needs to start a new week on Monday. The 'time_upload'
field is a datetime field. What am I doing wrong or not doing here ?
SELECT SUM(distance), DATE_FORMAT('time_upload', '%u'),
WEEK('time_upload', '7') FROM TRAININGLOG WHERE
DATE_SUB(NOW(),INTERVAL
7 DAY )
< =time_upload
If time_upload is a column, it should not be between single quotes in
the
WEEK() function.
---John Holmes...
--
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
Re: [PHP-DB] DATE_SUB Issues
What is should doing is grabbing all entries of this week and return a total. Its returning the wrong results. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 => Results: (This is wrong) => Weekly Miles: (Week starts on Monday) 5.34 Correct Results should be this: Weekly Miles: 30.5 ______ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> still no luck - any other suggestions? Please define "no luck" Yes of course. Here is my new query. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 So how does it not work? What are you expecting? What is returned? Is an error occuring or the wrong results or no results?? ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DATE_SUB Issues
WooHoo! I got it working! Basically what I did is I changed this DATE_SUB( NOW(),INTERVAL 7 DAY ) to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked. I am not entirely sure why. Anyone know? __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote: What is should doing is grabbing all entries of this week and return a total. Its returning the wrong results. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 => Results: (This is wrong) => Weekly Miles: (Week starts on Monday) 5.34 Correct Results should be this: Weekly Miles: 30.5 ______ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> still no luck - any other suggestions? Please define "no luck" Yes of course. Here is my new query. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 So how does it not work? What are you expecting? What is returned? Is an error occuring or the wrong results or no results?? ---John Holmes... -- 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
Re: [PHP-DB] DATE_SUB Issues
Thanks - I'll play with it today. __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 30, 2004, at 3:32 AM, Ricardo Lopes wrote: sorry, i press Control+Enter and i send the unfinished mail, here is the continuation: it worked because it was monday, probably today you arent happy. try this sql, but i dont like the GROUP clause SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1) FROM TRAININGLOG WHERE (WEEK(NOW(), 1) <= WEEK(time_upload, 1)) GROUP BY time_upload LIMIT 1 - Original Message - From: "Craig Hoffman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 29, 2004 9:48 PM Subject: Re: [PHP-DB] DATE_SUB Issues WooHoo! I got it working! Basically what I did is I changed this DATE_SUB( NOW(),INTERVAL 7 DAY ) to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked. I am not entirely sure why. Anyone know? ______ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _____ On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote: What is should doing is grabbing all entries of this week and return a total. Its returning the wrong results. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 => Results: (This is wrong) => Weekly Miles: (Week starts on Monday) 5.34 Correct Results should be this: Weekly Miles: 30.5 __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> still no luck - any other suggestions? Please define "no luck" Yes of course. Here is my new query. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 So how does it not work? What are you expecting? What is returned? Is an error occuring or the wrong results or no results?? ---John Holmes... -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] DATE_SUB Issues
sorry about the multiple reply's. I tested the query with a few future dates and it seemed to be worked. Thanks again for your help. Thanks - Craig __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 30, 2004, at 3:32 AM, Ricardo Lopes wrote: sorry, i press Control+Enter and i send the unfinished mail, here is the continuation: it worked because it was monday, probably today you arent happy. try this sql, but i dont like the GROUP clause SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1) FROM TRAININGLOG WHERE (WEEK(NOW(), 1) <= WEEK(time_upload, 1)) GROUP BY time_upload LIMIT 1 - Original Message - From: "Craig Hoffman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 29, 2004 9:48 PM Subject: Re: [PHP-DB] DATE_SUB Issues WooHoo! I got it working! Basically what I did is I changed this DATE_SUB( NOW(),INTERVAL 7 DAY ) to DATE_SUB( NOW(),INTERVAL 1 DAY ) and it worked. I am not entirely sure why. Anyone know? ______ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _____ On Mar 29, 2004, at 10:56 AM, Craig Hoffman wrote: What is should doing is grabbing all entries of this week and return a total. Its returning the wrong results. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, 1) FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 => Results: (This is wrong) => Weekly Miles: (Week starts on Monday) 5.34 Correct Results should be this: Weekly Miles: 30.5 __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Mar 29, 2004, at 10:29 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> On Mar 29, 2004, at 10:06 AM, John W. Holmes wrote: From: "Craig Hoffman" <[EMAIL PROTECTED]> still no luck - any other suggestions? Please define "no luck" Yes of course. Here is my new query. SELECT SUM(distance), DATE_FORMAT(time_upload, '%u'), WEEK(time_upload, '7') FROM TRAININGLOG WHERE DATE_SUB( NOW(),INTERVAL 7 DAY ) <= time_upload GROUP BY time_upload LIMIT 1 So how does it not work? What are you expecting? What is returned? Is an error occuring or the wrong results or no results?? ---John Holmes... -- 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 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] Graphing - bar charts
Hi there: I am looking for an open source and simple PHP script that will graph (bar) a few MySQL fields. Does anyone have any recommendations? __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] include function
Someone tell me why this isn't working? I keep getting a parser error
on line 36 (the last include). I'm running PHP 4.3.5 if that helps.
include ("include/dbadmin.php");
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");
Parse error: parse error, unexpected T_INCLUDE in
/Users/choffman/Sites/www/cyclistsedge/top_performace.php on line 36
______
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] include function
Ok, I figured it out. I am using jpgraph and I need to place the
include statement next to the start of PHP.
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
On Apr 6, 2004, at 10:24 PM, Craig Hoffman wrote:
Someone tell me why this isn't working? I keep getting a parser error
on line 36 (the last include). I'm running PHP 4.3.5 if that helps.
include ("include/dbadmin.php");
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");
Parse error: parse error, unexpected T_INCLUDE in
/Users/choffman/Sites/www/cyclistsedge/top_performace.php on line 36
______
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
--
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] Double Submission into DB if Hit Refresh
What is the best way to avoid data being resubmitted (entered twice) to DB (mysql) if the user hits refresh after POSTING data via a form? __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] compile 4.3.6
Hi, I am trying to recompile PHP 4.3.6 with GD support. I have installed libjpeg, libpng, and libtiff with Fink. Fink place all this stuff in the /sw directory. Every time I run ./configure I get this: If configure fails try --with-jpeg-dir= configure: error: libpng.(a|so) not found. Here is what I am running: ./configure --with-zlib-dir=/usr/local --with-libjpeg-dir=/sw --with-libpng-dir=/sw --with-libtiff-dir=/sw --with-gd --with-mysql=/usr/local/mysql --with-xml --with-freetype=/sw --with-pdflib=/sw --enable-ftp --enable-ldap --with-freetype-dir=/sw --with-curl=/sw --with-apxs=/usr/sbin/apxs What's interesting is I update another machine with PHP 4.3.5 with GD / Fink and it work perfectly. Anyone have any ideas? Thanks - CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] compile 4.3.6
Hi Jason and list, Yes your right about the two machines... I changed the libjpeg, libpng, libtiff to this: --with-jpeg-dir=/sw \ --with-png-dir=/sw/ \ --with-tiff-dir=/sw / --with-gd \ I get this when I run the configure: checking for GD support... yes checking for the location of libjpeg... /sw checking for the location of libpng... /sw but the configure then stops and I get this error: configure: error: libjpeg.(a|so) not found. Ideas? __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Apr 20, 2004, at 2:05 AM, Jason Wong wrote: On Tuesday 20 April 2004 09:31, Craig Hoffman wrote: Here is what I am running: ./configure --with-zlib-dir=/usr/local --with-libjpeg-dir=/sw --with-libpng-dir=/sw --with-libtiff-dir=/sw --with-gd --with-mysql=/usr/local/mysql --with-xml --with-freetype=/sw --with-pdflib=/sw --enable-ftp --enable-ldap --with-freetype-dir=/sw --with-curl=/sw --with-apxs=/usr/sbin/apxs Your configuration options seems to be a complete mess. AFAIK there are no options such as "--with-libjpeg-dir" etc. Use './configure --help | less' to see what you should really e using. What's interesting is I update another machine with PHP 4.3.5 with GD / Fink and it work perfectly. Anyone have any ideas? It's only interesting if both machines have the exact same configuration. Otherwise find out what the difference is to figure out why one is working and the other not. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* enhance, v.: To tamper with an image, usually to its detriment. */ -- 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
Re: [PHP-DB] compile 4.3.6
Hi everyone, I got working. Here is my configure that worked: ./configure' '--with-zlib-dir=/usr/local/' '--with-gd' '--with-jpeg-dir=/sw' '--with-png-dir=/sw' '--with-mysql=/usr/local/mysql' '--with-xml' '--with-pdflib-dir=/sw' '--enable-ftp' '--enable-ldap' '--with-curl=/sw' '-enable-calendar' '--with-expat-dir=/sw' '--enable-mime-magic' '--disable-debug' '--enable-pic' '--enable-sysvsem' '--enable-sysvshm' '--enable-exif' '--with-gettext=/sw' '--with-ncurses' '--with-dom' '--with-apxs=/usr/sbin/apxs' Thanks - CH __ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Apr 20, 2004, at 7:34 AM, Craig Hoffman wrote: Hi Jason and list, Yes your right about the two machines... I changed the libjpeg, libpng, libtiff to this: --with-jpeg-dir=/sw \ --with-png-dir=/sw/ \ --with-tiff-dir=/sw / --with-gd \ I get this when I run the configure: checking for GD support... yes checking for the location of libjpeg... /sw checking for the location of libpng... /sw but the configure then stops and I get this error: configure: error: libjpeg.(a|so) not found. Ideas? ______ Craig Hoffman - eClimb Media v: (847) 644 - 8914 f: (847) 866 - 1946 e: [EMAIL PROTECTED] w: www.eclimb.net _ On Apr 20, 2004, at 2:05 AM, Jason Wong wrote: On Tuesday 20 April 2004 09:31, Craig Hoffman wrote: Here is what I am running: ./configure --with-zlib-dir=/usr/local --with-libjpeg-dir=/sw --with-libpng-dir=/sw --with-libtiff-dir=/sw --with-gd --with-mysql=/usr/local/mysql --with-xml --with-freetype=/sw --with-pdflib=/sw --enable-ftp --enable-ldap --with-freetype-dir=/sw --with-curl=/sw --with-apxs=/usr/sbin/apxs Your configuration options seems to be a complete mess. AFAIK there are no options such as "--with-libjpeg-dir" etc. Use './configure --help | less' to see what you should really e using. What's interesting is I update another machine with PHP 4.3.5 with GD / Fink and it work perfectly. Anyone have any ideas? It's only interesting if both machines have the exact same configuration. Otherwise find out what the difference is to figure out why one is working and the other not. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* enhance, v.: To tamper with an image, usually to its detriment. */ -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Image / file uploader
I have a script where it uploads a image to directory. I have used
the script several times and it works when I send the form to another
page. The problem is I have changed the form to submit to itself and I
can't seem to get it to work.
echo (" ");
The thing is all my other fields update except for the image. Further,
the image does not even show up if I echo the query out.
UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race =
'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE
user_id = '1'
Here is the code of the image uploader and my query, perhaps someone
could take a look let me know what I'm missing.
Thanks - CH
if($_POST["postback_bio"])
{
include "include/dbadmin.php";
//image uploader
$uploadpath = '/images/clients/';
$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest = '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Bio has been successfully
stored. ");
} else {
echo ("Image could not be stored.");
}
}
} else {
echo ("No new image supplied.");
$photo_name = $oldimage;
}
//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];
$query = "UPDATE users SET bio = '$bio', goals = '$goals', fav_race =
'$fav_race', fav_train = '$fav_train', photo_name = '$photo_name'
WHERE user_id = '$user_id'";
echo $query;
$msg = "Could not update
record";
$result = mysql_query($query, $db);
}
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
When I put single quotes in the PHP_SELF and I get this error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING
and I can't use double quotes because its in an echo statement. What
am I missing?
echo ("
Any more thoughts?
CH
______
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 29, 2004, at 6:49 PM, Daniel Clark wrote:
I think you want single quotes around PHP_SELF.
"$_SERVER['PHP_SELF']"
I have a script where it uploads a image to directory. I have used
the script several times and it works when I send the form to another
page. The problem is I have changed the form to submit to itself and
I
can't seem to get it to work.
echo (" ");
The thing is all my other fields update except for the image.
Further,
the image does not even show up if I echo the query out.
UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race
=
'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE
user_id = '1'
Here is the code of the image uploader and my query, perhaps someone
could take a look let me know what I'm missing.
Thanks - CH
if($_POST["postback_bio"])
{
include "include/dbadmin.php";
//image uploader
$uploadpath = '/images/clients/';
$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest = '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Bio has been
successfully
stored. ");
} else {
echo ("Image could not be
stored.");
}
}
} else {
echo ("No new image supplied.");
$photo_name = $oldimage;
}
//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];
$query = "UPDATE users SET bio = '$bio', goals = '$goals', fav_race =
'$fav_race', fav_train = '$fav_train', photo_name = '$photo_name'
WHERE user_id = '$user_id'";
echo $query;
$msg = "Could not update
record";
$result = mysql_query($query, $db);
}
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
--
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Sorry to be a pest but I tried that. It giving me the same error.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 29, 2004, at 7:10 PM, Daniel Clark wrote:
Change to double quotes for the HTML portion.
action=\"$_SERVER['PHP_SELF']\"
When I put single quotes in the PHP_SELF and I get this error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING
and I can't use double quotes because its in an echo statement. What
am I missing?
echo ("
Any more thoughts?
CH
______
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 29, 2004, at 6:49 PM, Daniel Clark wrote:
I think you want single quotes around PHP_SELF.
"$_SERVER['PHP_SELF']"
I have a script where it uploads a image to directory. I have used
the script several times and it works when I send the form to
another
page. The problem is I have changed the form to submit to itself
and
I
can't seem to get it to work.
echo (" ");
The thing is all my other fields update except for the image.
Further,
the image does not even show up if I echo the query out.
UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test',
fav_race
=
'Fav Races - test', fav_train = 'Traing -test', photo_name = ''
WHERE
user_id = '1'
Here is the code of the image uploader and my query, perhaps someone
could take a look let me know what I'm missing.
Thanks - CH
if($_POST["postback_bio"])
{
include "include/dbadmin.php";
//image uploader
$uploadpath = '/images/clients/';
$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest = '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Bio has been
successfully
stored. ");
} else {
echo ("Image could not be
stored.");
}
}
} else {
echo ("No new image supplied.");
$photo_name = $oldimage;
}
//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];
$query = "UPDATE users SET bio = '$bio', goals = '$goals',
fav_race =
'$fav_race', fav_train = '$fav_train', photo_name = '$photo_name'
WHERE user_id = '$user_id'";
echo $query;
$msg = "Could not update
record";
$result = mysql_query($query, $db);
}
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
--
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 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Fellows, thanks for helping. But still no luck. The error is gone, but
the image / file is still not showing up in the query. What else I can
provide to help trouble shoot this?
echo ("");
______
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 29, 2004, at 7:32 PM, Micah Stevens wrote:
Do this:
echo (" ");
PHP doesn't handle array's well in echo statements, so you have to
stop the
echo, concat the array, and then continue the echo.
-Micah
On Thursday 29 April 2004 04:46 pm, Craig Hoffman wrote:
I have a script where it uploads a image to directory. I have used
the script several times and it works when I send the form to another
page. The problem is I have changed the form to submit to itself and
I
can't seem to get it to work.
echo (" ");
The thing is all my other fields update except for the image.
Further,
the image does not even show up if I echo the query out.
UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race
=
'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE
user_id = '1'
Here is the code of the image uploader and my query, perhaps someone
could take a look let me know what I'm missing.
Thanks - CH
if($_POST["postback_bio"])
{
include "include/dbadmin.php";
//image uploader
$uploadpath = '/images/clients/';
$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest = '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Bio has been
successfully
stored. ");
} else {
echo ("Image could not be
stored.");
}
}
} else {
echo ("No new image supplied.");
$photo_name = $oldimage;
}
//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];
$query = "UPDATE users SET bio = '$bio', goals = '$goals', fav_race =
'$fav_race', fav_train = '$fav_train', photo_name = '$photo_name'
WHERE user_id = '$user_id'";
echo $query;
$msg = "Could not update
record";
$result = mysql_query($query, $db);
}
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
--
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
Re: [PHP-DB] Image / file uploader
This is really becoming an irritating small bug. I tried the curly
brackets and the photo name still does not show up when I echo out the
query. Everything else about the script works fine. Why does PHP
choke on forms that submit files to themselves? I am slowly running
out things to try...
Suggestions?
Thanks for everyone's help.
CH
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 30, 2004, at 5:05 AM, Ford, Mike [LSS] wrote:
On 30 April 2004 01:10, Craig Hoffman wrote:
When I put single quotes in the PHP_SELF and I get this error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING
and I can't use double quotes because its in an echo statement. What
am I missing?
Curly braces:
echo ("
Cheers!
Mike
-
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Image / file uploader
Hans,
Thanks Hans. I tried what your suggested and still no luck.
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 30, 2004, at 7:57 AM, Hans Lellelid wrote:
Craig Hoffman wrote:
> This is really becoming an irritating small bug. I tried the curly
> brackets and the photo name still does not show up when I echo out
the
> query. Everything else about the script works fine. Why does PHP
choke
> on forms that submit files to themselves? I am slowly running out
> things to try...
>
> Suggestions?
Remove the action attribute of your tag. Default is to post
back to same page.
>>echo ("> encType='multipart/form-data'>
Also yuk!
Have you considered at the very least separating your presentation
layer out into separate files so that you don't echo() your HTML?
This will make your life easier if ever you want some non-PHP person
to help w/ layout. It'll also make your life easier if you want to
redesign the form later w/o having to muck around in your processing
logic or if you want to add caching to your site. It'll also make
your life easier if you want to move templates out of the web root or
want to change your app design to use an object-oriented application
framework (like Mojavi, Binarycloud, etc.). etc., etc., etc.
Hans
--
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
Re: [PHP-DB] Image / file uploader
Here you go: I mostly echo out the HTML. I have included the entire
form here.
Thanks - CH
echo ("");
echo ("
Name:
$row[name]");
echo ("");
echo ("");
if ($row["photo_name"] != '') {
echo (" ");
} else {
$photo_name = ' ';
}
echo("
Bio:
$row[bio]
Goals:
$row[goals]
Favorite Race:
$row[fav_race]
Favorite Place to Train:
$row[fav_train]
Upload Photo:
");
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 30, 2004, at 8:47 AM, Chris Boget wrote:
Thanks Hans. I tried what your suggested and still no luck.
What does the actual HTML form look like?
Chris
--
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
Re: [PHP-DB] Image / file uploader
No problem - Here you go. Thanks - CH
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
eClimb Media and RaceLogix Traininglog
Welcome to Training
log
Home
Login
Mailing List
Contact
Coaching
Group Runs
Featured Athlete
Utilities
Logout
Edit Your Bio
Tell us a little about yourself.
No new image supplied.
UPDATE users SET bio = 'Hello World - Bio', goals = 'Hello World -
Goal', fav_race = 'Hello World - Race', fav_train = 'Hello World -
Trainingf', photo_name = '' WHERE user_id = '12'
Name:
Craig Hoffman
Bio:
Hello
World - Bioing
Goals:
Hello
World - Goaling
Favorite Race:
Hello World - Raceing
Favorite Place to Train:
Hello World - Trainingfsdf
Upload Photo:
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 30, 2004, at 8:56 AM, Hans Lellelid wrote:
> Here you go: I mostly echo out the HTML. I have included the
entire
> form here.
> Thanks - CH
>
> echo ("
> encType='multipart/form-data'>");
> echo ("
> ...
If you could send the actual resulting HTML that is echoed by your
script, that would be more helpful in diagnosing why your browser
isn't posting back to the right page.
HL
--
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
Re: [PHP-DB] Image / file uploader
Sure - I never thought i would have some many issues with a "simple"
postback. ;)
Here 's the code:
function display_edit_bio($user_id)
{
if($_POST['postback_bio'])
{
include "include/dbadmin.php";
//image uploader
$uploadpath = 'images/clients/';
$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest != '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Bio has been successfully
stored. ");
} else {
echo ("Image could not be stored.");
}
}
} else {
echo ("No new image supplied.");
$photo_name = $oldimage;
}
//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];
$query = "UPDATE users SET bio = '$bio', goals = '$goals', fav_race =
'$fav_race', fav_train = '$fav_train', photo_name = '$photo_name'
WHERE user_id = '$user_id'";
echo $query;
$msg = "Could not update
record";
$result = mysql_query($query, $db) or ($msg);
}
?>
______
Craig Hoffman
iChat: m0untaind0g
__
On Apr 30, 2004, at 9:17 AM, Hutchins, Richard wrote:
Craig,
Where is the code that actually handles the image upload? Is it in
/~choffman/www/mtrain/client_profile.php? If so, can you post that too?
Rich
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, April 30, 2004 10:08 AM
To: Hans Lellelid
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Image / file uploader
No problem - Here you go. Thanks - CH
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
eClimb Media and RaceLogix Traininglog
Welcome
to Training
log
Home
Login
Mailing List
Contact
Coaching
Group Runs
Featured Athlete
Utilities
Logout
Edit Your Bio
Tell us a little about yourself.
No new image supplied.
UPDATE users SET bio = 'Hello World - Bio', goals = 'Hello World -
Goal', fav_race = 'Hello World - Race', fav_train = 'Hello World -
Trainingf', photo_name = '' WHERE user_id = '12'
Name:
Craig Hoffman
Bio:
Hello
World - Bioing
Goals:
Hello
World - Goaling
Favorite Race:
Hello World - Raceing
Re: [PHP-DB] Image / file uploader
That worked! Han's and everyone else thank you very much. I owe
everyone who helped out a beer. ;)
Thanks CH
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimbmedia.com
_
On Apr 30, 2004, at 9:22 AM, Hans Lellelid wrote:
Errr $HTTP_POST_FILES is not superglobal (am I wrong?)
$_FILES or specify global $HTTP_POST_FILES
Hans
Craig Hoffman wrote:
function display_edit_bio($user_id)
{
if($_POST['postback_bio'])
{
include "include/dbadmin.php";
//image uploader
$uploadpath = 'images/clients/';
$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest != '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Bio has been
successfully stored. ");
} else {
echo ("Image could not be
stored.");
}
}
} else {
echo ("No new image supplied.");
$photo_name = $oldimage;
}
//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];
$query = "UPDATE users SET bio = '$bio', goals = '$goals',
fav_race = '$fav_race', fav_train = '$fav_train', photo_name =
'$photo_name' WHERE user_id = '$user_id'";
echo $query;
$msg = "Could not update
record";
$result = mysql_query($query, $db) or ($msg);
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Query help
Hey Everyone, I can use some help here I have query where one can selects an "style" then a "area" and finally "rating" through a drop menu. When some selects a rating they select a range of ratings. For example: Style: Traditional Area: Yosemite Rating: From: 5.5 To: 5.10c This should pull up all the rock climbs that are in Yosemite, that are traditional style and are between the rating 5.5 to 5.10c. Here is my query: "SELECT * FROM routes, users WHERE area='$area' AND style='$style' BETWEEN rating='[$rating1]' AND rating='[$rating2]' GROUP BY route ORDER BY rating ASC "; For some reason which I am not seeing, this query is not doing what it should be doing. Does anyone have any suggestions? Thanks, Craig -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] NULL and empty space
I have an form where someone can choose to upload a photo. If the
person does not upload a photo, an emtpy string is inserted in the DB.
How can I have it insert 'NULL' in the DB instead of an empty string
when they choose NOT to upload a photo but complete the form anyway?
Any help is appreciated!
Much Thanks -- CH
Here is my code and query if it helps:
if($_POST["postback_upload"])
{
include "include/db.php";
//image uploader
$uploadpath = 'images/climbs/';
$source = $_FILES['photo']['tmp_name'];
$route_photo = $_FILES['photo']['name'];
$dest == '';
if (($source != 'none') && ($source != '')) {
$dest = $uploadpath.$route_photo;
if ($dest != '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Climbing log has been successfully
stored. ");
} else {
echo ("Image could not be stored.");
}
}
} else {
echo ("No new image supplied. Climbing long has been
successfully stored.");
}
//photo uploader - make "route_photo" a varible for MySQL to work --
need to find out why.
$query = "INSERT INTO routes(user_id , date_climbed , route , pitchs
, rating, area, outcrop, type, style, private_comments,
public_comments, stars, route_photo)
VALUES('NULL', '$_POST[date_climbed]', '$_POST[route]',
'$_POST[pitchs]', '$_POST[rating]',
'$_POST[area]', '$_POST[outcrop]', '$_POST[type]', '$_POST[style]',
'$_POST[private_comments]','$_POST[public_comments]','$_POST[stars]',
'$route_photo')";
echo $query;
$msg = "Could not insert record";
$result = mysql_query($query,$db) or die(mysql_error());
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: NULL and empty space
I've tried that and thanks. Bad news is I still can't get it to work.
Its always the simple things that causes problems.
Any other suggestions?
On Aug 22, 2004, at 10:41 AM, Daniel Schierbeck wrote:
Craig Hoffman wrote:
I have an form where someone can choose to upload a photo. If the
person does not upload a photo, an emtpy string is inserted in the
DB. How can I have it insert 'NULL' in the DB instead of an empty
string when they choose NOT to upload a photo but complete the form
anyway?
Any help is appreciated!
Much Thanks -- CH
Here is my code and query if it helps:
if($_POST["postback_upload"])
{
include "include/db.php";
//image uploader
$uploadpath = 'images/climbs/';
$source = $_FILES['photo']['tmp_name'];
$route_photo = $_FILES['photo']['name'];
$dest == '';
if (($source != 'none') && ($source != '')) {
$dest = $uploadpath.$route_photo;
if ($dest != '') {
if (move_uploaded_file($source, $dest)) {
echo ("Image and Climbing log has been
successfully stored. ");
} else {
echo ("Image could not be stored.");
}
}
} else {
echo ("No new image supplied. Climbing long has been
successfully stored.");
}
//photo uploader - make "route_photo" a varible for MySQL to
work -- need to find out why.
$query = "INSERT INTO routes(user_id ,
date_climbed , route , pitchs , rating, area, outcrop, type, style,
private_comments, public_comments, stars, route_photo)
VALUES('NULL', '$_POST[date_climbed]', '$_POST[route]',
'$_POST[pitchs]', '$_POST[rating]',
'$_POST[area]', '$_POST[outcrop]', '$_POST[type]',
'$_POST[style]',
'$_POST[private_comments]','$_POST[public_comments]','$_POST[stars]',
'$route_photo')";
echo $query;
$msg = "Could not insert
record";
$result = mysql_query($query,$db) or die(mysql_error());
Why not just check if it's an empty string, and replace it with NULL
if so?
if ($route_photo = '') {
$route_photo = NULL;
}
I'm not completely sure though.
--
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] Register Globals = OFF not passing variable
Hey Folks,
I can use some help here. I am changing some scripts around so they
work with (register) globals off. I am trying to pass variables in a
function and it does not seem to be passing. The script work fine
with globals turned on. I would really like to have them work with RG
turned off. Any help would be appreciated. Here is a short example:
function display_private_results($user_id, $area, $username)
{
if ($_POST['postback_private_results'])
{
include "include/db.php";
$query = "SELECT routes.*, users.* FROM users, routes WHERE
area='$area' AND username='$username' ";
and so on...
Much Thanks,
Craig
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Register Globals = OFF not passing variable
My apologies for not being clear. ;)
I am not getting an error message. The script works just fine when
Register Globals are turned on in the php.ini file. I am simply trying
to understand what I need to change in order to have RG off and still
have my code to work. See the area of the code where the functions
start
function display_private_results($user_id, $area, $username)
This seems to be the problem area. These variables are not being
passed when registered globals are turned OFF.
On Sep 24, 2004, at 8:51 PM, M Saleh EG wrote:
nothing's clear !!
What's the error that u get?
wat does the function get or return??
is it a variable scope problem? or what... I dont get the picture..
maybe u should paste the error ur getting..
On Fri, 24 Sep 2004 20:12:46 -0500, Craig Hoffman
<[EMAIL PROTECTED]> wrote:
Hey Folks,
I can use some help here. I am changing some scripts around so they
work with (register) globals off. I am trying to pass variables in a
function and it does not seem to be passing. The script work fine
with globals turned on. I would really like to have them work with RG
turned off. Any help would be appreciated. Here is a short example:
function display_private_results($user_id, $area, $username)
{
if ($_POST['postback_private_results'])
{
include "include/db.php";
$query = "SELECT routes.*, users.* FROM users,
routes WHERE
area='$area' AND username='$username' ";
and so on...
Much Thanks,
Craig
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
M.Saleh.E.G
97150-4779817
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Register Globals = OFF not passing variable
Daniel,
Thanks. Thats what I was looking for.
Regards,
Craig
On Sep 24, 2004, at 9:40 PM, Daniel Watrous wrote:
Craig,
I don't see where you are calling the function
"display_private_results",
but I think I know what you are after. It appears you are expecting
POST
data and so have used the _POST superglobal. You have one of two
options:
Option 1:
call the function sending parameters as you have shown below, but use
superglobals
e.g. display_private_results($_POST["user_id"], $_POST["area"],
$_POST["username"]);
NOTE: this would make it seem a little awkward to use the _POST super
global
inside the function you may want to put it outside the function
Option 2:
call the function sending NO parameters
e.g. display_private_results()
and re-write your function to look like this:
function display_private_results()
{
if ($_POST['postback_private_results'])
{
include "include/db.php";
$query = "SELECT routes.*, users.* FROM users, routes WHERE
area='$_POST["area"]' AND username='$_POST["username"]' ";
and so on...
Hope this helps. If it doesn't I suspect that some reading on
superglobals
will resolve your dilemma...
http://www.php.net/manual/en/language.variables.predefined.php
Daniel Watrous
- Original Message -
From: "Craig Hoffman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 24, 2004 7:12 PM
Subject: [PHP-DB] Register Globals = OFF not passing variable
Hey Folks,
I can use some help here. I am changing some scripts around so they
work with (register) globals off. I am trying to pass variables in a
function and it does not seem to be passing. The script work fine
with globals turned on. I would really like to have them work with RG
turned off. Any help would be appreciated. Here is a short example:
Much Thanks,
Craig
--
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] Names with apostrophe's
Hello,
I could use some help here. I have an entry in the MySQL, that use an
apostrophe, for example lets call it "O'Reilly". I have added
addslashes to my insert statement so MySQL accepts it with out
complaining.
The problem I am having is I use this information "O'Reilly" in a GET
URL somewhere else in the site.
For example here's my link:
echo("
Re: [PHP-DB] Names with apostrophe's
Thanks everyone.
urlencode worked like a charm.
On Sep 29, 2004, at 3:53 PM, GH wrote:
You need to use the urlencode() function
On Wed, 29 Sep 2004 13:23:07 -0500, Craig Hoffman
<[EMAIL PROTECTED]> wrote:
Hello,
I could use some help here. I have an entry in the MySQL, that use an
apostrophe, for example lets call it "O'Reilly". I have added
addslashes to my insert statement so MySQL accepts it with out
complaining.
The problem I am having is I use this information "O'Reilly" in a GET
URL somewhere else in the site.
For example here's my link:
echo("
[PHP-DB] dropdown list - help
I can use some help here. I have page where a user can make updates to
a DB record. The user can then select items from a drop down list.
I'm trying to get my drop down list to pull from the MySQL and have the
value that is stored in MySQL be the one selected in the option
selected tag . So if the user does
not edit this field the original value remains unchanged.
For example:
All the other options to choose from
The tricky part is the actual value, in this case the ($rating) is
stored in a table called routes. The options which I want in the drop
down list are stored in a table called ranking. Both tables have a
rating column.
My apologies if this is not clear, its gets confusing trying to explain
it. Any help anyone can give would be great. Thanks - CH
Here is my code snippet:
The drop down list is marked with //Drop Down List
$route_count = $_POST["route_count"];
$username = $_POST["username"];
$user_id = $_POST["user_id"];
$fall = $_POST["fall"];
$rating = $_POST["rating"];
$query = "SELECT * FROM users, routes, ranking WHERE route_count =
'$route_count' AND username='$username' AND routes.rating =
ranking.rating';
echo $query;
$result = mysql_query($query,$db) or die(mysql_error());
if ($row = mysql_fetch_array($result))
{
echo ("");
echo ("
* Route:
* Area:
i.e: Yosemite
* Crag:
i.e.: Half Dome
Current Rating:
");
//Drop Down List
$rating = $_POST['rating'];
$options .="
if ($_POST['rating'] == "$rating") {
$options .=" selected=\"selected\"";
}
$options .=">$rating\n";
echo $options;
echo("");
The rest of the page...
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Assistance with if..elseif statement
I have this block of code which checks to see if an image has been
uploaded from an update form. Everything in the form works, except I
can not get the the elseif statements to behave properly. See the
comments below for explanation. Any help would be appreciated.
$route_photo = $_FILES['image']['name'];
// if no new image and no existing image put NULL in the DB
if(empty($_FILES['image']['name']) && ($_POST['oldimage']) == '')
{
$route_photo = 'NULL';
echo ("No image supplied.");
// if new image put the new image name in the DB
} elseif ($_POST['route_photo'] || $_FILES['image']['name']) {
$route_photo = $_POST['route_photo'];
echo ("The image has been replaced with
$route_photo.");
// If no new image update, use the old image
} elseif ($_POST['route_photo'] = $_POST['oldimage'])
{
$route_photo = $_POST['oldimage'];
echo("No new image supplied");
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: SV: [PHP-DB] Assistance with if..elseif statement
Thanks all - CH On Jan 17, 2005, at 8:35 AM, Henrik Hornemann wrote: Hi, } elseif ($_POST['route_photo'] = $_POST['oldimage']) Should probably be } elseif ($_POST['route_photo'] == $_POST['oldimage']) Regards Henrik Hornemann -----Oprindelig meddelelse- Fra: Craig Hoffman [mailto:[EMAIL PROTECTED] Sendt: 17. januar 2005 15:22 Til: [email protected] Emne: [PHP-DB] Assistance with if..elseif statement I have this block of code which checks to see if an image has been uploaded from an update form. Everything in the form works, except I can not get the the elseif statements to behave properly. See the comments below for explanation. Any help would be appreciated. $route_photo = $_FILES['image']['name']; // if no new image and no existing image put NULL in the DB if(empty($_FILES['image']['name']) && ($_POST['oldimage']) == '') { $route_photo = 'NULL'; echo ("No image supplied."); // if new image put the new image name in the DB } elseif ($_POST['route_photo'] || $_FILES['image']['name']) { $route_photo = $_POST['route_photo']; echo ("The image has been replaced with $route_photo."); // If no new image update, use the old image } elseif ($_POST['route_photo'] = $_POST['oldimage']) { $route_photo = $_POST['oldimage']; echo("No new image supplied"); } -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] checkboxes
I have a form that display's a checkbox if the value is NULL. The form
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update
statement in MySQL. THe problem is I am only getting one of the
checkboxes, even if all of them are checked. Here is my code block,
any help would be great. - Craig
//From form page
//MySQL Update Page
$email = $_POST['email'] == $route;
$completed = $_POST["completed"] == $route;
$route_name = trim($_POST["route_name"]) == $route;
$user_id = $_POST['user_id'] == $route;
$id = $_POST['id'] == $route;
$route = array(id => "$_POST[id]", completed => "$_POST[completed]",
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
foreach ($route as $key => $values) {
echo("");
echo $values;
//MySQL Update statement will go here.
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] checkboxes
I've tried that and it still doesn't bring over the other checkboxes that have been checked. Plus when I echo it out I get Array instead of the variable name. On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote: Probably all you need to do is name your checkboxes as an array thusly: name="completed[]" Then you can access the array on your update page and do whatever you wish with it. Hope this helps. Rich -Original Message- From: Craig Hoffman [mailto:[EMAIL PROTECTED] Sent: Friday, January 21, 2005 4:03 PM To: [email protected] Subject: [PHP-DB] checkboxes I have a form that display's a checkbox if the value is NULL. The form is in a do... while loop, so the user may check multiple checkboxes. I am trying to pass the variable of each checkboxes to an update statement in MySQL. THe problem is I am only getting one of the checkboxes, even if all of them are checked. Here is my code block, any help would be great. - Craig //From form page //MySQL Update Page $email = $_POST['email'] == $route; $completed = $_POST["completed"] == $route; $route_name = trim($_POST["route_name"]) == $route; $user_id = $_POST['user_id'] == $route; $id = $_POST['id'] == $route; $route = array(id => "$_POST[id]", completed => "$_POST[completed]", route_name => "$_POST[route_name]", user_id => "$_POST[user_id]"); foreach ($route as $key => $values) { echo(""); echo $values; //MySQL Update statement will go here. } -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] checkboxes
Great - Thanks. That worked fine. Now the next question. ;)
How can I update MySQL with the array values I just generated?
Basically if you checked two checkboxes, that represents two rows in
MySQL. How can I update those two rows in the DB?
code snippet
Array: Array ( [0] => Done (completed) [1] => 1 (user_id) [2] =>
Northeast Ridge (route_name) [3] => 2(id) [4] => Done [5] => 1 [6] =>
Kahiltna Spire [7] => 4 )
$com = array("$_POST[completed]", "$_POST[route_name]", "$_POST[id]",
"$_POST[user_id]");
print_r ($completed);
//foreach ($com as $key => $values) {
include "include/db.php";
$query = "UPDATE ticklist SET completed = '$completed' WHERE
route_name = '$route_name' AND id = '$id' AND user_id = '$user_id'";
echo $query;
$msg = "Could not insert
record";
$result = mysql_query($query,$db) or
die(mysql_error($msg));
Thanks - CH
On Jan 21, 2005, at 3:47 PM, Hutchins, Richard wrote:
You can't just echo out an array. You have to either use print_r() or
iterate over it with a while or for...next loop. But if you just want
to see
what's in the array, print_r() it.
As to why it doesn't bring over the other checkboxes...
If you have (pseudocode)
Checkbox 1
Checkbox 2
Checkbox 3
And you check the first two checkboxes, then the resulting array will
be
(pseudocode again):
completed(value1,value2)
And from there, you just access the array contents as you would with
any
other multidimensional array.
If you don't check anything on the page, then the array will be empty
and, I
think, won't even be sent in the $_POST array. I'm sure somebody will
correct me there if my memory has failed me.
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:32 PM
To: [email protected]
Cc: Richard Hutchins
Subject: Re: [PHP-DB] checkboxes
I've tried that and it still doesn't bring over the other checkboxes
that have been checked. Plus when I echo it out I get
Array instead of the variable name.
On Jan 21, 2005, at 3:14 PM, Hutchins, Richard wrote:
Probably all you need to do is name your checkboxes as an array
thusly:
name="completed[]"
Then you can access the array on your update page and do whatever you
wish
with it.
Hope this helps.
Rich
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: Friday, January 21, 2005 4:03 PM
To: [email protected]
Subject: [PHP-DB] checkboxes
I have a form that display's a checkbox if the value is NULL. The form
is in a do... while loop, so the user may check multiple checkboxes.
I am trying to pass the variable of each checkboxes to an update
statement in MySQL. THe problem is I am only getting one of the
checkboxes, even if all of them are checked. Here is my code block,
any help would be great. - Craig
//From form page
//MySQL Update Page
$email = $_POST['email'] == $route;
$completed = $_POST["completed"] == $route;
$route_name = trim($_POST["route_name"]) == $route;
$user_id = $_POST['user_id'] == $route;
$id = $_POST['id'] == $route;
$route = array(id => "$_POST[id]", completed => "$_POST[completed]",
route_name => "$_POST[route_name]", user_id => "$_POST[user_id]");
foreach ($route as $key => $values) {
echo("");
echo $values;
//MySQL Update statement will go here.
}
--
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 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] brackets []
Quick question... I am hoping some could explain this to me. I have an array like this: $completed = array($value1, $value2, $value3); where the values are sent via a form. when I do print_ r() to see what's in the array I get this: Array ( [0] => [1] => [2] => ) An empty array. But when I do this: $completed[] = array($value1, $value2, $value3); Array ( [0] => 1 [1] => 1 [2] => Done [3] => 2 [4] => 1 [5] => 3 [6] => 1 [7] => 4 [8] => 1 [9] => Array ( [0] => [1] => [2] => ) ) I get a multidimensional array with keys and values. How can I get this array to be one dimensional? Much Thanks - CH -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] if statement
Hi There,
I am trying to write an if statement to see if an array has any values
in it and if it does do something.
for example:
$ticklist2 = array("'$values")
if (array_values(empty($ticklist2))){
do something
} else {
do something else
}
I just can't get this to work. Any help would be great.
Thanks, Craig H.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Pear help
Hi There, I'm trying to configure my OS X box to work with PEAR. Everything seems to be working (updating PEAR libraries, etc.) except when I run my test script I get the following error: Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 271 Here is my test script: I've included the path in my PHP.INI file and I still get this error. I've tested this script on another PEAR server and it works fine. Does anyone have any ideas? If this is wrong list, my apologies. Any help would be greatly appreciated. - Craig -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pear help
Thanks for getting back to me... Comments below -
On Feb 28, 2005, at 10:49 AM, Martin Norland wrote:
Craig Hoffman wrote:
Hi There,
I'm trying to configure my OS X box to work with PEAR. Everything
seems to be working (updating PEAR libraries, etc.) except when I run
my test script I get the following error:
Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line
271
Here is my test script:
require 'DB.php';
if (class_exists('DB')){
print 'Ok';
} else {
print 'Nope';
}
?>
I've included the path in my PHP.INI file and I still get this error.
I've tested this script on another PEAR server and it works fine.
Does anyone have any ideas? If this is wrong list, my apologies.
Any help would be greatly appreciated.
Comment out the 'require' line - and run your test script. I expect
you'll get the result "Ok". If so, you have something somewhere
that's already including DB.php.
If I comment out the //require it prints my else statement 'Nope'
Are you running this test script from within something, or do you
actually include some 'common libraries' (your own custom, or some
frameworks?). You may also try changing it to require_once, in case
something is already require'ing it.
I've tried require_once and it just gives me another error:
Ok
Fatal error: Class 'PEAR_Error' not found in /usr/lib/php/DB.php on
line 728
The error is clearly stating that there's already a "class DB"
defined. It's defined somewhere.
I'm not sure if this relevant, but I have used db.php (another file) in
an include statements to connect mysql for a few websites.
Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily
represent those of St. Jude Children's Research Hospital.
--
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] Grouping Data Together
Hello,
I could use some assistance here. I'll try and explain this the best I
can. I'm trying to get this query to work where it pulls up all the
rows that are associated with a common id . For example let say you
have data that you want to group together. For example:
Group 1 would look like this:
Title 1
Abstract for title 1
- articles that belong to title 1
- articles that belong to title 1
Then group two:
Title 2
Abstract for title 2
- articles that belong to title 2
- articles that belong to title 2
and so forth
Basically my script is working, it queries the correct results, but it
only pulls up one set of results (title 1), instead of ALL results. I
am including the code below, perhaps someone could take a look at it?
I hope this makes sense? :)
- Craig
$query = "SELECT * FROM clients, articles WHERE clients.id =
articles.id GROUP BY co_name ORDER BY date_uploaded";
$result = mysql_query($query, $db) or die(mysql_error());
echo("Client List");
while ($row = mysql_fetch_array($result)) {
$co_name = $row['co_name'];
$co_logo = $row['co_logo'];
$co_text = $row['co_text'];
$corp_name = array("$co_name");
print_r ($corp_name);
foreach ($corp_name as $corp1_name) {
$rc = "\r";
if ($co_logo = $co_logo) {
echo ("");
}
echo("");
echo ereg_replace($rc, '', trim(stripslashes("$corp1_name")));
echo ereg_replace($rc, '', trim(stripslashes("$co_text")));
$query = "SELECT articles.*, clients.id FROM articles, clients WHERE
clients.id = articles.id AND co_name = '$corp1_name' GROUP BY
article_name ORDER BY date_uploaded";
//echo $query;
$result = mysql_query($query, $db) or die(mysql_error());
echo("");
while ($row = mysql_fetch_array($result)) {
$article_name = $row['article_name'];
echo("$article_name");
}
echo("");
echo("");
}
}
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Grouping Data Together
Found the problem - Craig
On Mar 10, 2005, at 5:47 PM, Craig Hoffman wrote:
Hello,
I could use some assistance here. I'll try and explain this the best
I can. I'm trying to get this query to work where it pulls up all the
rows that are associated with a common id . For example let say you
have data that you want to group together. For example:
Group 1 would look like this:
Title 1
Abstract for title 1
- articles that belong to title 1
- articles that belong to title 1
Then group two:
Title 2
Abstract for title 2
- articles that belong to title 2
- articles that belong to title 2
and so forth
Basically my script is working, it queries the correct results, but
it only pulls up one set of results (title 1), instead of ALL results.
I am including the code below, perhaps someone could take a look at
it? I hope this makes sense? :)
- Craig
$query = "SELECT * FROM clients, articles WHERE clients.id =
articles.id GROUP BY co_name ORDER BY date_uploaded";
$result = mysql_query($query, $db) or die(mysql_error());
echo("Client List");
while ($row = mysql_fetch_array($result)) {
$co_name = $row['co_name'];
$co_logo = $row['co_logo'];
$co_text = $row['co_text'];
$corp_name = array("$co_name");
print_r ($corp_name);
foreach ($corp_name as $corp1_name) {
$rc = "\r";
if ($co_logo = $co_logo) {
echo ("");
}
echo("");
echo ereg_replace($rc, '', trim(stripslashes("$corp1_name")));
echo ereg_replace($rc, '', trim(stripslashes("$co_text")));
$query = "SELECT articles.*, clients.id FROM articles, clients WHERE
clients.id = articles.id AND co_name = '$corp1_name' GROUP BY
article_name ORDER BY date_uploaded";
//echo $query;
$result = mysql_query($query, $db) or die(mysql_error());
echo("");
while ($row = mysql_fetch_array($result)) {
$article_name = $row['article_name'];
echo("$article_name");
}
echo("");
echo("");
}
}
?>
--
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] GD Question
Hello Everyone,
I wrote a GD function that resizes some images and displays them as
thumbnails. When I put the function in the index.php page I receive an
error Warning: Headers have already been sent... then it shows a bunch
of binary. I do not want re-save the file, I just want resize and show
it. What am I doing wrong here? Any help would be great.
- Craig
//query the DB for image name
Some query...
//Photo varibale
$route_photo = $row["route_photo"];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header("Content-type: image/jpeg");
//Start new image resize
list($width_orig, $height_orig) =
getImageSize("./images/climbs/$route_photo");
if ($new_width && ($width_orig < $height_orig)) {
$new_width = ($new_height / $height_orig) * $width_orig;
} else {
$new_height = ($new_width / $width_orig) * $height_orig;
}
//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG("./images/climbs/$route_photo");
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width_orig, $height_orig);
ImageJPEG($thumb,'','100');
ImageDestroy($thumb);
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] GD Question
The script works fine when I test it on a stand alone page. I'm just
not sure how to include with the "rest" of the site.
On Apr 5, 2005, at 1:17 PM, Philip Hallstrom wrote:
Probably nothing really. When it complains about headers already
being sent is the line number the same as your header() line below?
If so, that means you're outputting something back to the browser
prior to that line.
I'd make sure you don't have any white space before your initial
opening
-philip
On Tue, 5 Apr 2005, Craig Hoffman wrote:
Hello Everyone,
I wrote a GD function that resizes some images and displays them as
thumbnails. When I put the function in the index.php page I receive
an error Warning: Headers have already been sent... then it shows a
bunch of binary. I do not want re-save the file, I just want resize
and show it. What am I doing wrong here? Any help would be great.
- Craig
//query the DB for image name
Some query...
//Photo varibale
$route_photo = $row["route_photo"];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header("Content-type: image/jpeg");
//Start new image resize list($width_orig, $height_orig) =
getImageSize("./images/climbs/$route_photo");
if ($new_width && ($width_orig < $height_orig)) {
$new_width = ($new_height / $height_orig) * $width_orig;
} else {
$new_height = ($new_width / $width_orig) * $height_orig;
}
//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG("./images/climbs/$route_photo");
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width_orig, $height_orig);
ImageJPEG($thumb,'','100');
ImageDestroy($thumb);
--
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
Re: [PHP-DB] GD Question
Thanks - it works perfectly! On Apr 5, 2005, at 1:33 PM, Simon Rees wrote: On Tuesday 05 April 2005 19:19, Craig Hoffman wrote: The script works fine when I test it on a stand alone page. I'm just not sure how to include with the "rest" of the site. You can't do it all from the same script (AFAIK). This is because of the way http/browsers work - each image is requested as a separate file. Put your image code in a separate script and request it in the src attribute of your html image tags. e.g. Simon -- ~~ Simon Rees | [EMAIL PROTECTED] | ORA-03113: end-of-file on communication channel ~~ -- 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
Re: [PHP-DB] GD Question
Hi Wendell, If its not too much trouble, I have one more question. How can I get GD to give me the correct image name and pass a variable to another page. So the image corresponds with the correct title in the DB. Does that make sense? Thanks again. Craig On Apr 5, 2005, at 1:41 PM, Wendell Frohwein wrote: So, your index.php page is the one with the image in it. How are you calling the image? When I do something similar, In my index.php page I would of course have the html code: My doimage.php is the actual code to retrieve / create the thumbnail for you. If you were trying to have the code that creates the thumbnail in your index.php, this explains why you were getting binary information in your code. I hope that helps. PS You might want to try creating thumbnails when you initially upload your image. This saves on cpu power. Yes I know. Thanks. -Wendell -Original Message- From: Craig Hoffman [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 05, 2005 11:04 AM To: [email protected] Subject: [PHP-DB] GD Question Hello Everyone, I wrote a GD function that resizes some images and displays them as thumbnails. When I put the function in the index.php page I receive an error Warning: Headers have already been sent... then it shows a bunch of binary. I do not want re-save the file, I just want resize and show it. What am I doing wrong here? Any help would be great. - Craig //query the DB for image name Some query... //Photo varibale $route_photo = $row["route_photo"]; //Start GD //New Image resize $new_width = 125; $new_height = 225; //Content Type header("Content-type: image/jpeg"); //Start new image resize list($width_orig, $height_orig) = getImageSize("./images/climbs/$route_photo"); if ($new_width && ($width_orig < $height_orig)) { $new_width = ($new_height / $height_orig) * $width_orig; } else { $new_height = ($new_width / $width_orig) * $height_orig; } //resample the image $thumb = ImageCreateTrueColor($new_width, $new_height); $tmp_image = ImageCreateFromJPEG("./images/climbs/$route_photo"); ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); ImageJPEG($thumb,'','100'); ImageDestroy($thumb); -- 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] One more GD ? -- filename
Thanks everyone for answering my other post. However, I'm still having
trouble passing the image name from the GD script to the image tag.
I'm including the GD script below. Any help would be great. Thanks -
Craig
//GD script
include ("db.php");
$query = "SELECT route_photo FROM routes WHERE route_photo IS NOT NULL
ORDER BY RAND() LIMIT 1";
$result = mysql_query($query, $db) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
//Photo varibale
$route_photo = $row["route_photo"];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header("Content-type: image/jpeg");
//Start new image resize
list($width_orig, $height_orig) =
getImageSize("../images/climbs/$route_photo");
if ($new_width && ($width_orig < $height_orig)) {
$new_width = ($new_height / $height_orig) * $width_orig;
} else {
$new_height = ($new_width / $width_orig) * $height_orig;
}
//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG("../images/climbs/$route_photo");
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width,
$new_height, $width_orig, $height_orig);
ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?>
//Image Tag:
echo ("");
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] One more GD ? -- filename
I believe the problem is somewhere in the GD script. Because when I view the source it shows an empty variable. I should at least see the name of variable in the source. Any ideas? On Apr 6, 2005, at 9:46 AM, Bastien Koert wrote: Have a look here...I have some sample code on calling images from a db. It used the two pages like you do here and passes the ID back and forth to the image production page...maybe it will help http://www.weberdev.com/get_example-4062.html bastien From: Craig Hoffman <[EMAIL PROTECTED]> To: [email protected] Subject: [PHP-DB] One more GD ? -- filename Date: Wed, 6 Apr 2005 08:23:40 -0500 Thanks everyone for answering my other post. However, I'm still having trouble passing the image name from the GD script to the image tag. I'm including the GD script below. Any help would be great. Thanks - Craig //GD script include ("db.php"); $query = "SELECT route_photo FROM routes WHERE route_photo IS NOT NULL ORDER BY RAND() LIMIT 1"; $result = mysql_query($query, $db) or die(mysql_error()); while($row = mysql_fetch_array($result)) { //Photo varibale $route_photo = $row["route_photo"]; //Start GD //New Image resize $new_width = 125; $new_height = 225; //Content Type header("Content-type: image/jpeg"); //Start new image resize list($width_orig, $height_orig) = getImageSize("../images/climbs/$route_photo"); if ($new_width && ($width_orig < $height_orig)) { $new_width = ($new_height / $height_orig) * $width_orig; } else { $new_height = ($new_width / $width_orig) * $height_orig; } //resample the image $thumb = ImageCreateTrueColor($new_width, $new_height); $tmp_image = ImageCreateFromJPEG("../images/climbs/$route_photo"); ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); ImageJPEG($thumb, $route_photo, '100'); ImageDestroy($thumb); } ?> //Image Tag: echo (""); -- 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
Re: [PHP-DB] One more GD ? -- filename
Hi Jos, I understand what your saying. The problem is all the image names are listed in the DB (image.jpg, image1.jpg and so on) and all images have titles attached. For example, Title: Large Green Sea Turtle Image: LargeGreenSeaTurtle.jpg As you can see, the GD script randomly pulls photo names from the DB and shows them. When I output the image with using the image tag I get a blank variable. Since the image name is empty, I can not match/query the title and image. The image output may be showing a Blue Sea Turtle but the title says, Green Sea Turtle. If I could just get the image name, I could run a query to match them. Does this make sense? On Apr 6, 2005, at 10:36 AM, Juffermans, Jos wrote: Hi, If I understand correctly, you're using "include/function_gd.php?route_photo=$thumb" as image source which is the script you pasted. If you use a script as image source, the script should output the image data - not just store the image. I'm not sure what you're trying to do but if you have an image object in php (eg $thumb), you should output that image: output instead of save) exit(); ?> However, you cannot use that to show multiple images from 1 script. Jos -Original Message- From: Craig Hoffman [mailto:[EMAIL PROTECTED] Sent: 06 April 2005 15:24 To: [email protected] Subject: [PHP-DB] One more GD ? -- filename Thanks everyone for answering my other post. However, I'm still having trouble passing the image name from the GD script to the image tag. I'm including the GD script below. Any help would be great. Thanks - Craig //GD script while($row = mysql_fetch_array($result)) { //Photo varibale $route_photo = $row["route_photo"]; //Start GD //New Image resize $new_width = 125; $new_height = 225; //Content Type header("Content-type: image/jpeg"); //Start new image resize list($width_orig, $height_orig) = getImageSize("../images/climbs/$route_photo"); if ($new_width && ($width_orig < $height_orig)) { $new_width = ($new_height / $height_orig) * $width_orig; } else { $new_height = ($new_width / $width_orig) * $height_orig; } //resample the image $thumb = ImageCreateTrueColor($new_width, $new_height); $tmp_image = ImageCreateFromJPEG("../images/climbs/$route_photo"); ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); ImageJPEG($thumb, $route_photo, '100'); ImageDestroy($thumb); } ?> //Image Tag: echo (""); -- 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 Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] One more GD ? -- filename
Hi There (again),
My apologies for being a complete pest with this issue. I changed a
few things around and I can now pass the image name thanks to Jos,
however, I'm getting a permission errors now.
Warning: imagejpeg(): Unable to open 'corneilus.jpg' for writing
I've changed image folder and subfolder permissions to 777 and no luck.
Any ideas.
Again thanks your help. :)
Craig
On Apr 6, 2005, at 11:18 AM, Juffermans, Jos wrote:
Hi,
Are you trying to display more images at once then?
You can store the image like you do now, then have the GD script
output the
image tag and use the image you've just stored as a source.
GD script:
...
ImageJPEG($thumb, $route_photo, '100');
echo ''; // add this line
ImageDestroy($thumb);
...
in the other script instead of
echo ("");
do this:
require("include/function_gd.php?route_photo=$thumb");
Jos
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 18:12
To: [email protected]
Cc: Juffermans, Jos
Subject: Re: [PHP-DB] One more GD ? -- filename
Hi Jos,
I understand what your saying. The problem is all the image names are
listed in the DB (image.jpg, image1.jpg and so on) and all images have
titles attached. For example,
Title: Large Green Sea Turtle
Image: LargeGreenSeaTurtle.jpg
As you can see, the GD script randomly pulls photo names from the DB
and shows them. When I output the image with using the image tag I get
a blank variable.
Since the image name is empty, I can not match/query the title and
image. The image output may be showing a Blue Sea Turtle but the
title says, Green Sea Turtle. If I could just get the image name, I
could run a query to match them. Does this make sense?
On Apr 6, 2005, at 10:36 AM, Juffermans, Jos wrote:
Hi,
If I understand correctly, you're using
"include/function_gd.php?route_photo=$thumb" as image source which is
the
script you pasted. If you use a script as image source, the script
should
output the image data - not just store the image.
I'm not sure what you're trying to do but if you have an image object
in php
(eg $thumb), you should output that image:
output instead of save)
exit();
?>
However, you cannot use that to show multiple images from 1 script.
Jos
-Original Message-
From: Craig Hoffman [mailto:[EMAIL PROTECTED]
Sent: 06 April 2005 15:24
To: [email protected]
Subject: [PHP-DB] One more GD ? -- filename
Thanks everyone for answering my other post. However, I'm still
having
trouble passing the image name from the GD script to the image tag.
I'm including the GD script below. Any help would be great. Thanks -
Craig
//GD script
while($row = mysql_fetch_array($result)) {
//Photo varibale
$route_photo = $row["route_photo"];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header("Content-type: image/jpeg");
//Start new image resize
list($width_orig, $height_orig) =
getImageSize("../images/climbs/$route_photo");
if ($new_width && ($width_orig < $height_orig)) {
$new_width = ($new_height / $height_orig) *
$width_orig;
} else {
$new_height = ($new_width / $width_orig) *
$height_orig;
}
//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image =
ImageCreateFromJPEG("../images/climbs/$route_photo");
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0,
$new_width,
$new_height, $width_orig, $height_orig);
ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?>
//Image Tag:
echo ("");
--
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 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] Headers sent error msg on one server but not the other...
Hey Folks,
I have a script that times out the session if there is no activity in a
certain amount of time. If there is no activity the HEADER()
redirects to the logout page and kills the session. Everything works
fine on our test server, but when I test the script on the production
server, I get an error "HEADERS ALREADY SENT..." after no activity. I
know all this stuff needs to be on top, before any XHTML.
The test server has reg globals = OFF and the production server has
them set to ON. I can't change the any PHP.INI settings on the
production server. Both servers are running PHP 4.3.10. Other than
that PHP installation is close to identical. Any ideas / thoughts on
what's causing the production server to send this error out? Something
to steer me in the right direction... I'm attaching a code snippet to
look at:
if (mysql_num_rows($result) > 0) {
$_SESSION["valid_user"] = $email;
}
elseif ($t_timestamp < $c_timestamp) {
HEADER("Location: logout.php");
exit;
}
Best,
CH
__
Craig Hoffman
ICQ / iChat: m0untaind0g
__
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Headers sent error msg on one server but not the other.... .
Thanks guys. There was a space after the closing ?> tag.
Best,
Craig
On Apr 28, 2005, at 2:08 PM, Patel, Aman wrote:
Check that there is no output generated before your script hits the
Header() function calls. The most common mistake I've noticed is that
if you require() or include() many files before you call Header(), and
if there is any content outside of the "" tags in the
includ()'ed or require()'d files (eg. a carraige return at the end, or
a space after the "?>".
Check for that and that should fix your problem.
Craig Hoffman wrote:
Hey Folks,
I have a script that times out the session if there is no activity in
a certain amount of time. If there is no activity the HEADER()
redirects to the logout page and kills the session. Everything works
fine on our test server, but when I test the script on the production
server, I get an error "HEADERS ALREADY SENT..." after no activity.
I know all this stuff needs to be on top, before any XHTML.
The test server has reg globals = OFF and the production server has
them set to ON. I can't change the any PHP.INI settings on the
production server. Both servers are running PHP 4.3.10. Other than
that PHP installation is close to identical. Any ideas / thoughts
on what's causing the production server to send this error out?
Something to steer me in the right direction... I'm attaching a code
snippet to look at:
if (mysql_num_rows($result) > 0) {
$_SESSION["valid_user"] = $email;
}
elseif ($t_timestamp < $c_timestamp) {
HEADER("Location: logout.php");
exit;
}
Best,
CH
__
Craig Hoffman
ICQ / iChat: m0untaind0g
__
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
__
Craig Hoffman
ICQ / iChat: m0untaind0g
__
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Session handler - Info wanted
Hi There, I'm going to write my own session handler for an upcoming project. I would like to store the session data in MySQL. I've never written one before; so if anyone has any tips, suggestions, in-sight, etc... please share. Thanks, Craig _______ Craig Hoffman www.eclimb.net [EMAIL PROTECTED] iChat / AIM: m0untaind0g ___ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Classes and Includes
Hi There, Question: How do I include a file or another class, such as a database connection (table, username, password, etc...) into a class? I don't want to to change the username and password on every class(file) that I upload to the server? I'm just picking up this OO stuff, I'm sort of a newbee. ;) Any help would be appreciated. For example: Thanks, Craig -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Manipulate an image automatically
I've used GD several times, it works well and its easy to use. http://us2.php.net/manual/en/function.gd-info.php Craig Hoffman IM: m0untaind0g On Apr 13, 2006, at 9:52 AM, Henry Ortega wrote: What is the quickest way to manipulate an image? I have a 300x100 image of something (template), and I want text to be inserted to that graphic at a certain coordinate (e.g. lower right), how would I do that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Restaurant menu
Hey there, I'm working on a menu system for a catering company. I'm having a difficult time sorting and grouping items together. For example, there may be three or four appetizers that should be group together. But I only want to display the category (appetizers) once and then the corresponding items (A, B, C,...). I'm drawing a blank on how to go about this. My DB consists of 4 tables (categories, items, item_attributes, menu) but the menu table is most the important. The menu schema is below. menu_id menu_name menu_category => pulls from the categories table (appetizers, starters, etc...) menu_item => pulls from the items table (Cherry Pie) menu_item_atttribute => pulls from the attribute table (Hot, cold, etc) Example: Menu Name: x Appetizers A B C D Desserts A B I'm open to all suggestions / ideas. Thanks - Craig -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Inheritance question
Hi there,
I could use some help in understanding inheritance and accessing
certain properties in objects.
For example (see below), lets say I would like to use "public $one"
property in a new class / method (such as class b)? What is the
best way to accomplish this? Any help and or suggestions are welcome.
class a {
public $one;
public function someMethod() {
$this->one = '1';
}
}
class b {
public $two
function someOtherMethod() {
$this->two = '2';
}
}
- CH
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysqli_prepare
Can you use the mysqli_prepare function to UPDATE MySQL or is it just limited to an INSERT statement? For example. $stmt = mysqli_prepare($db, 'UPDATE proj_overview SET proj_id = ?, proj_name = ?, ... and so on... mysqli_stmt_bind_para... mysqli_stmt_execute... Thanks, CH Craig Hoffman IM / iChat: m0untaind0g -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Universal Update / Delete Script
Hey There - I could use some suggestions / advice here. I have to create several update and delete scripts for two different areas of a site. For example "Update the News, Update an Event, Delete News, Delete Event" and so on. Instead of writing 4 separate scripts that updates and / or deletes records in MySQL, what would be the best approach in having an 2 universal scripts that updates and another one that just deletes? Does this make sense? Here's a breakdown: Events - Update / Delete (events table) News - Update / Delete (news table) _______ Craig Hoffman iChat / AIM: mountain.dog ___ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
