[PHP-DB] data formats
I'm submitting form data which is a mixture of checkboxes and text inputs, some of which are integers and a couple text based. I am retrieving the data as follows: $var = (int)!empty($_POST['var']); for checkboxes, $var = (int)$_POST['var']; for integers and $var = mysql_real_escape_string($_POST['var']); Is this correct? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Online PHP-Mysql Meeting
If anyone has any ideas for a tutorial, create a list. Others can add to it. Then those interested in creating tutorials can select the idea(s) from the list they are most familiar with. How does that sound? - Original Message - From: Gunawan Wibisono landavi...@gmail.com To: php-db@lists.php.net Sent: Friday, March 19, 2010 12:16 PM Subject: Re: [PHP-DB] Online PHP-Mysql Meeting that's good idea u have another tutorial to share? On Fri, Mar 19, 2010 at 7:02 PM, David McGlone da...@dmcentral.net wrote: perhaps u can editing.. u perhaps not have something to share.. but you can give something like.. comment or anything that helpfull How does a tutorial on setting up and using SMARTY sound? I use SMARTY in a lot of my projects and could probably give a tutorial on that. -- Blessings David M. I have been driven to my knees many times by the overwhelming conviction that I had nowhere else to go. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- akan ada dimana mulut terkunci dan suara tak ada lagi.. saat itu gunakanlah HP untuk melakukan SMS!! - ini aliran bedul.. bukan aliran aneh. tertawa sebelum tertawa didepan RSJ.. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Online PHP-Mysql Meeting
Due to time zone differences, people in various zones (countries/continents) can only avail of a live event within a certain time period. A recorded presentation can be viewed by anyone anytime anywhere. No time zone constraints. Obviously, whoever is taking on the role of tutor in a live event has their own time restrictions/schedule, so I think if this is is going to be a live event, see who is available/able to take on the role of tutor in various zones so everyone else knows which live event best suits their own schedule if they want to attend/tune in. Then decide/debate on the best available format for the event and any associated QA. Richard - Original Message - From: nagendra prasad nagendra802...@gmail.com To: PHP DB php-db@lists.php.net; phpexpe...@yahoogroups.com Sent: Thursday, March 18, 2010 10:46 AM Subject: [PHP-DB] Re: Online PHP-Mysql Meeting Hi All, As we are discussing about how to roll out this meeting from past 3-4 days Taygun ALBAN has raised an important point about the meeting (Thanks Taygun for pointing out this). As we all know we don't live in the same country, so their will be some difference between each one's time zone. Taygun has pointed out that we all are from different time zone so how we are going to roll out this meeting? Guys please pitch in and think about this issue. We will have to come with some solution so that all of us can attend this meeting. Also, I think now its time to decide a date for the meeting. Please suggest a date as well. Best, Guru. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Online PHP-Mysql Meeting
Well if it could be subtitled in any way, that would solve the problem, and again I say IF. Richard. - Original Message - From: David McGlone da...@dmcentral.net To: php-db@lists.php.net Sent: Thursday, March 18, 2010 12:07 PM Subject: Re: [PHP-DB] Online PHP-Mysql Meeting I think we should either consider audio or video Audio would make it impossible for the hearing impaired :-( -- Blessings David M. I have been driven to my knees many times by the overwhelming conviction that I had nowhere else to go. -- 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] resources and resource types
When I did a search on resource(5) within the PHP online documentation, I found the resource page resource.php. While although it lists all the resources used with mysql, it does not mention how resources are related to resource numbers as above. A query such as a row count on a table results in an integer value. What is the best way of accessing or converting the integer value from the resource? I can't see any particular function in the function list which does this, without getting into strings or arrays, or have I missed something blaringly obvious, hope not? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql_num_rows, resource id #
In my code below, I am trying to verify that the query is selecting data from both rows of my answers table. I have run the query on my MySQL CLI and getting answers from both rows, but running this script I get $rows = 0. I can't figure out why its not returning 2 for the number of rows. It is not giving me any error msgs such as cannot connect. Also can tell me where I can find documentation on resource id #, such as resource(5)? ?PHP DEFINE (host,localhost); DEFINE (user,root); DEFINE (password,pasword); DEFINE (database,questions); $connection=mysql_connect(host,user,password) or die ('Could not connect' . mysql_error() ); $dbConnect=mysql_select_db('questions',$connection); if (!$dbConnect) {die ('Could not connect to database' . mysql_error() );} $result = mysql_query(Select answer from answers where studentID='A123456789') or die(mysql_error()); $rows = mysql_num_rows($result); echo $rows; ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP-DB] mysql_num_rows, resource id #
This much is working: ?PHP ini_set('error_reporting',E_All); DEFINE (host,localhost); DEFINE (user,root); DEFINE (password,password); DEFINE (database,questions); $connection=mysql_connect(host,user,password) or die ('Could not connect' . mysql_error() ); $dbConnect=mysql_select_db('questions'); if (!$dbConnect) {die ('Could not connect to database' . mysql_error() );} $result = mysql_query(Select answer from answers where studentID='A123456789') or die(mysql_error()); $rows = mysql_num_rows($result); echo $rows . \n; $answer = mysql_fetch_row($result); foreach($answer as $a) { echo $a; } ? The output is 1 1 which is correct. One small step at a time, hopefully forward. Richard. ---BeginMessage--- Richard Dunne wrote: In my code below, I am trying to verify that the query is selecting data from both rows of my answers table. I have run the query on my MySQL CLI and getting answers from both rows, but running this script I get $rows = 0. I can't figure out why its not returning 2 for the number of rows. It is not giving me any error msgs such as cannot connect. Also can tell me where I can find documentation on resource id #, such as resource(5)? ?PHP DEFINE (host,localhost); DEFINE (user,root); DEFINE (password,pasword); DEFINE (database,questions); $connection=mysql_connect(host,user,password) or die ('Could not connect' . mysql_error() ); $dbConnect=mysql_select_db('questions',$connection); if (!$dbConnect) {die ('Could not connect to database' . mysql_error() );} $result = mysql_query(Select answer from answers where studentID='A123456789') or die(mysql_error()); $rows = mysql_num_rows($result); echo $rows; ? Still no luck then. Try selecting the DB without the connection parameter: $dbConnect=mysql_select_db('questions'); And don't forget to set error_reporting(E_ALL) above your code. ---End Message--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Resource id #5
Can someone explain how I can translate Resource id #5 which is what I am getting from the code below? $result = mysql_query(Select answer from answers) or die(mysql_error()); $resultArray = explode(',',$result); for ($i=0;$isizeof($resultArray);$i++) { echo $resultArray[$i]; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
- Original Message - From: Chris [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 2:18 am Subject: Re: [PHP-DB] numeric string to single digit array Richard Dunne wrote: Sorry for the top-posting, it's my mail client, not my design. I honestly have not even looked at myphpadmin much, using the CLI mostly. It's easy enough to click to another place in your mail client ;) So what happens when you run that query manually? -- Postgresql php tutorials http://www.designmagick.com/ I ran this $query =Select answer from answers where studentID ='A123456789'; $result = mysql_query($query,$connection); $resultArray = str_split($result,1); $count = count($resultArray); As I have two rows in my table, count should, at least I hope, return a value of two, but it doesn't. It returns 1. From what I can assertain, str_split is seeing a two digit number and not splitting it into two single digit numbers. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 3:12 pm Subject: Re: [PHP-DB] numeric string to single digit array I ran this $query =Select answer from answers where studentID ='A123456789'; $result = mysql_query($query,$connection); $resultArray = str_split($result,1); $count = count($resultArray); Where's the fetch? |$result = mysql_query(SELECT answer FROM answers WHERE studentID = 'A123456789';); $count = 0; while ($row = mysql_fetch_assoc($result)) { $count++; } |Of course you should count in the query if the result itself is not used: |$result = mysql_query(SELECT COUNT(answer) AS nr_of_results FROM answers WHERE studentID = 'A123456789';); $row = mysql_fetch_assoc($result); $count = $row['||nr_of_results||'];|| | Evert PHP is telling me that the resource I am using for mysql_fetch_assoc is invalid: $query =Select answer from answers where studentID ='A123456789'; $result = mysql_query($query,$connection); $count=0; while($row = mysql_fetch_assoc($result)); { $count++; } echo $count; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 3:39 pm Subject: Re: [PHP-DB] numeric string to single digit array PHP is telling me that the resource I am using for mysql_fetch_assoc is invalid: $query =Select answer from answers where studentID ='A123456789'; $result = mysql_query($query,$connection); $count=0; while($row = mysql_fetch_assoc($result)); { $count++; } echo $count; Are you sure your database connection has been made? $connection = mysql_connect('localhost', 'mysql_user', 'mysql_password') or die(mysql_error()); etc.. If the connection is made alright, try: $query =Select answer from answers where studentID ='A123456789'; $result = mysql_query($query,$connection) or die(mysql_error()); $count=0; while($row = mysql_fetch_assoc($result)); { $count++; } echo $count; This is my code. The only error is at line 15 as I stated above. 1 ?PHP 2 DEFINE (host,localhost); 3 DEFINE (user,root); 4 DEFINE (password,password); 5 DEFINE (database,questions); 6 7 $connection=mysql_connect(host,user,password) or die ('Could not connect' .mysql_error() ); 8 9 $dbConnect=mysql_select_db('questions',$connection); 10 if (!$dbConnect) {die ('Could not connect to database' . mysql_error() );} 11 12 $query =Select answer from answers where studentID ='A123456789'; 13 $result = mysql_query($query,$connection); 14 $count=0; 15 while($row = mysql_fetch_assoc($result)); 16 { 17 $count++; 18 } 19 echo $count; 20 ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 4:04 pm Subject: Re: [PHP-DB] numeric string to single digit array This is my code. The only error is at line 15 as I stated above. 1 ?PHP 2 DEFINE (host,localhost); 3 DEFINE (user,root); 4 DEFINE (password,password); 5 DEFINE (database,questions); 6 7 $connection=mysql_connect(host,user,password) or die ('Could not connect' .mysql_error() ); 8 9 $dbConnect=mysql_select_db('questions',$connection); 10 if (!$dbConnect) {die ('Could not connect to database' . mysql_error() );} 11 12 $query =Select answer from answers where studentID ='A123456789'; 13 $result = mysql_query($query,$connection); 14 $count=0; 15 while($row = mysql_fetch_assoc($result)); 16 { 17 $count++; 18 } 19 echo $count; 20 ? Turn line 13 into $result = mysql_query($query) or die(mysql_error()); , so leave out the connection parameter and append the die() function, and see what error that produces. OK. Tried that and count comes back as 1. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 4:30 pm Subject: Re: [PHP-DB] numeric string to single digit array OK. Tried that and count comes back as 1. So your query returns only one record. Try $query =Select answer from answers; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Tried that as well and got the same result. I tried Select count(answer) as total from answers where studentID='A123456789'; from the CLI and got total = 2 as a result. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
- Original Message - From: Evert Lammerts [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 5:22 pm Subject: Re: [PHP-DB] numeric string to single digit array Tried that as well and got the same result. I tried Select count(answer) as total from answers where studentID='A123456789'; from the CLI and got total = 2 as a result. So, we got rid of the Invalid Resource error and we know that the student id you use occurs in both rows in your table and that your query works fine. Did you get rid of the semicolon @ line 15 while($row = mysql_fetch_assoc($result));, as Jason suggested? Also, an: error_reporting(E_ALL); at the top of your code might help in backtracing. The semi-colon is gone, although I didn't even notice it! I am using two different queries, one for count and the other to access the data itself. After running mysql_fetch_assoc, is foreach ok for accessing array members, or is there a more subtle approach? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP-DB] numeric string to single digit array
Using this extract from http://ie.php.net/manual/en/control-structures.foreach.php Amaroq 09-Mar-2008 06:40 Even if an array has only one value, it is still an array and foreach will run it. ?php $arr[] = I'm an array.; if(is_array($arr)) { foreach($arr as $val) { echo $val; } } ? The above code outputs: I'm an array. - So if I use: $query = Select answer from answers where studentID='A123456789'; $result = mysql_query($query,$connection) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { foreach($row as $answer) { echo $answer . \n; } } I thought I would be able to print out each array element, but I am not getting any output. Has anyone got a better idea? ---BeginMessage--- Tried that as well and got the same result. I tried Select count(answer) as total from answers where studentID='A123456789'; from the CLI and got total = 2 as a result. So, we got rid of the Invalid Resource error and we know that the student id you use occurs in both rows in your table and that your query works fine. Did you get rid of the semicolon @ line 15 while($row = mysql_fetch_assoc($result));, as Jason suggested? Also, an: error_reporting(E_ALL); at the top of your code might help in backtracing. ---End Message--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fwd: Re: [PHP-DB] numeric string to single digit array
I did var_dump on the result resource and I got resource(5) of type (mysql result). ---BeginMessage--- On Mar 26, 2008, at 12:30 PM, Evert Lammerts wrote: OK. Tried that and count comes back as 1. So your query returns only one record. Try $query =Select answer from answers; Why not do a var_dump() on $result to verify that it is a mysql result resource and then verify the count of rows with: mysql_num_rows($result); ---End Message--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] numeric string to single digit array
Can anyone tell me how how to convert a string of integers into an array of single digit integers. i.e. 1223123 into ['1','2,','2','3','1,'2','3'] ? When I retreive a column of single digit integers I end up with a long string of numbers. I think PHP is seeing this as one whole number and therefore is not splitting or exploding it. I hope I am wrong in my thinking and there is a simple solution, though I am not seeing it. Can anyone help me? Richard. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] numeric string to single digit array
Sorry for the top-posting, it's my mail client, not my design. I honestly have not even looked at myphpadmin much, using the CLI mostly. - Original Message - From: Chris [EMAIL PROTECTED] Date: Wednesday, March 26, 2008 0:53 am Subject: Re: [PHP-DB] numeric string to single digit array Please always CC the mailing list so others can learn and also contribute answers. Also please don't top-post as it makes it hard to follow discussions. Richard Dunne wrote: I am using MySQL and retrieving a single column which consists of single digit integers. I have been doing a lot of chopping and changing of my code. $query =Select answer from answers where studentID ='A123456789'; What do you get if you run this query manually through phpmyadmin or a similar tool? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php