Can't fetch result twice in a PHP script

2007-09-15 Thread Mahmoud Badreddine
I am using mysql 4.1.11 and PHP 5

In one of my php scripts I make 2 successive calls of mysql_fetch_row using
the same Mysql Result.
In the first call the desired result is achieved, but in the second one it
isn't.

I have something like
while($someArr=mysql_fetch_row($result))
{
...some code.
}

The first time I call mysql_fetch_row , the code inside the while loop gets
executed, but not the second time. What is the reason behind that.


-- 
-Mahmoud Badreddine

http://www.spreadfirefox.com/


Re: Can't fetch result twice in a PHP script

2007-09-15 Thread Mahmoud Badreddine
it is more of a PHP question , I admit.
I tried mysql_fetch_array, mysql_data_seek, mysql_result . Same result.
And I am sure there's more than zero rows to be fetched, because it works in
the first call, but not the second.

On 9/15/07, Chris Sansom [EMAIL PROTECTED] wrote:

 At 16:35 -0500 15/9/07, Mahmoud Badreddine wrote:
 In one of my php scripts I make 2 successive calls of mysql_fetch_row
 using
 the same Mysql Result.
 In the first call the desired result is achieved, but in the second one
 it
 isn't.
 
 I have something like
 while($someArr=mysql_fetch_row($result))
 {
 ...some code.
 }
 
 The first time I call mysql_fetch_row , the code inside the while loop
 gets
 executed, but not the second time. What is the reason behind that.

 Sounds more like a PHP question really, but have you thought about
 trying mysql_fetch_array() instead? I can't see why it should be any
 different, but it might be worth a shot - always works for me anyway.
 :-)

 But also: are you confident there's more than one row to be fetched?

 --
 Cheers... Chris
 Highway 57 Web Development -- http://highway57.co.uk/

 He who slings mud, usually loses ground.
 -- Adlai Stevenson




-- 
-Mahmoud Badreddine

http://www.spreadfirefox.com/


Re: Inserting null values in mysql with PHP

2007-08-09 Thread Mahmoud Badreddine
Hi
I added the following statement at the end of the my.cnf file:

sql-mode=STRICT_ALL_TABLES,ALLOW_INVALID_DATES

but I still got the values 0 and 0.00 where no values were entered.
I did restart the the mysql daemon of course.
What am I still doing wrong?

Thanks.



On 8/8/07, Christian High [EMAIL PROTECTED] wrote:

 On 8/8/07, Brent Baisley [EMAIL PROTECTED] wrote:
  One thing to check is to make sure you are not quoting your NULL
  value for your insert statement. MySQL will try to convert that to a
  numeric value, which may end up as 0.
 
  On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote:
 
   Hello
   I have a table which contain a few numerical values.
   I set the default values to be NULL.
   When I insert values using phpMyAdmin, it sets the values to NULL
   correctly.
   But when I insert using a PHP script that I wrote it sets the values
   to 0.00or 0.
   In my script I do test if the values are empty and in case they are
   I set
   the variable to NULL. But that still doesn't help.
   Is that a mysql problem ?
   Thank you.
  
   --
   -Mahmoud Badreddine
  
   http://www.spreadfirefox.com/
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
 
 
 As long as you are testing to see if they should be null, and the
 default is set to null, you could exclude the column all together from
 the insert statement and you should see they are then recorded in the
 table as null.

 cj




-- 
-Mahmoud Badreddine

http://www.spreadfirefox.com/


Re: Inserting null values in mysql with PHP

2007-08-09 Thread Mahmoud Badreddine
I did remove that column from the insert statement and no text appeared at
all in that field under that column. Not even the word NULL.

On 8/8/07, Christian High [EMAIL PROTECTED] wrote:

 On 8/8/07, Brent Baisley [EMAIL PROTECTED] wrote:
  One thing to check is to make sure you are not quoting your NULL
  value for your insert statement. MySQL will try to convert that to a
  numeric value, which may end up as 0.
 
  On Aug 8, 2007, at 12:55 PM, Mahmoud Badreddine wrote:
 
   Hello
   I have a table which contain a few numerical values.
   I set the default values to be NULL.
   When I insert values using phpMyAdmin, it sets the values to NULL
   correctly.
   But when I insert using a PHP script that I wrote it sets the values
   to 0.00or 0.
   In my script I do test if the values are empty and in case they are
   I set
   the variable to NULL. But that still doesn't help.
   Is that a mysql problem ?
   Thank you.
  
   --
   -Mahmoud Badreddine
  
   http://www.spreadfirefox.com/
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
 
 
 As long as you are testing to see if they should be null, and the
 default is set to null, you could exclude the column all together from
 the insert statement and you should see they are then recorded in the
 table as null.

 cj




-- 
-Mahmoud Badreddine

http://www.spreadfirefox.com/


Inserting null values in mysql with PHP

2007-08-08 Thread Mahmoud Badreddine
Hello
I have a table which contain a few numerical values.
I set the default values to be NULL.
When I insert values using phpMyAdmin, it sets the values to NULL correctly.
But when I insert using a PHP script that I wrote it sets the values
to 0.00or 0.
In my script I do test if the values are empty and in case they are I set
the variable to NULL. But that still doesn't help.
Is that a mysql problem ?
Thank you.

-- 
-Mahmoud Badreddine

http://www.spreadfirefox.com/


How to set table-specific privileges

2007-06-11 Thread Mahmoud Badreddine

Hello,
I am trying to revoke all privileges from a user on a certain table in a
database.
I want the user to continue to have all his/her privileges intact for the
other tables though.

I used the statement REVOKE ALL PRIVILEGES on dbName.tableName from
thisUser;

But that doesn't seem to change anything.
The message always gives Query 0K, 0 rows affected...
What could I be missing.
Thank you.

--

http://www.spreadfirefox.com/


Problem with authentication

2007-04-04 Thread Mahmoud Badreddine

Hello to all
I had an old MySQL 4.0 running on a Windows Machine.
I removed that version and I installed the MySQL 5.0 .

When I went to run phpMyAdmin this is the error I receive.
#1251 - Client does not support authentication protocol requested by server;
consider upgrading MySQL client


Although the password that's in config.inc.php is the same as the one I use
on the MySQL command login and that one works fine.
What is still lingering from my old installation that's prventing me from
loggin in , if any. Thank you.



--


Field names truncated.

2007-03-29 Thread Mahmoud Badreddine

I recieved a database structure from a certain piece of software and I
exported all the tables to MySQL, only to find out that the field names were
cut short.
How can I make sure that the field names is large enough to accomodate the
longest field header?
Thank you.

--
-Mahmoud Badreddine

http://www.spreadfirefox.com/


Running a query on multiple databases

2005-05-03 Thread Mahmoud Badreddine
Hi,
I would like to run a query on two tables that reside in two distinct 
databases:

select * from db1.table1 join db2.table2;

This lists both tables adjacent to one another rather than in a sequential 
fashion as one would get if both tables came from the same database.
Is there a way to accomplish this task. 

Thank you.


-- 
-Mahmoud Badreddine


Database design question

2005-04-14 Thread Mahmoud Badreddine
Hello,
I have two questions:
I would like to know whether I am violating the principle of atomicity in 
doing the following:

I have a form which has a field with the following options: Choice1, choice2 
and choice3.
Each of the above choices have two further subchoices : subChoice1, 
subchoice2.

so in my form I have a pull-down list and these are the choices I have:
choice1-subchoice1
choice1-subchoice2
choice2-subchoice1


and so on.

Are these values atomical?

My other question is what are the repercussions of not putting a table in 
2nd and 3rd Normal Form.
Thank you.


-- 
-Mahmoud Badreddine


Converting Integer values to date type

2005-03-18 Thread Mahmoud Badreddine
Hello,
I have a table with separate integer values for the day, month and year.
I would like to group them all under one field of type date.
I tried a few commands but I haven't captured the right syntax yet.

so if the field names are dayVal,monthVal and YearVal in talbeDummy

I am doing the following
select str_to_date(DayVal.MonthVal.YearVal,'%d.%m.%Y') from tableDummy;

I also tried :
select cast('YearVal-MonthVal-DayVal' AS date) from tblDiagnostic;

In both cases I had syntax errors one just flat out didn't run and the
second one gave me Null values in the table.
I also converted the integer values to varchar and that didn't help either.

This is got to be simple to do.
Thanks in advance.
-- 
-Mahmoud Badreddine

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Converting Integer values to date type

2005-03-18 Thread Mahmoud Badreddine
I got it working , thank you.
I only could do what I wanted to do in multisteps however. I couldn't
figure out the nested querying , and it's bugging me.
Here's how I issued it.
mysql update tableDummy set newDate=(select
str_to_date('(concat(DayVal,.,MonthVal,.,YearVal))','%d.%m.%Y'));

And although I got an error, it did give all zero values for the
date(e.g -00-00)

no big deal now that I have what I want, but if someone can pick out
my error, would be greatly apreciated.





On Fri, 18 Mar 2005 13:31:14 -0600, Dan Nelson [EMAIL PROTECTED] wrote:
 In the last episode (Mar 18), Mahmoud Badreddine said:
  Hello,
  I have a table with separate integer values for the day, month and year.
  I would like to group them all under one field of type date.
  I tried a few commands but I haven't captured the right syntax yet.
 
  so if the field names are dayVal,monthVal and YearVal in talbeDummy
 
  I am doing the following
  select str_to_date(DayVal.MonthVal.YearVal,'%d.%m.%Y') from tableDummy;
 
  CONCAT(DayVal, ., MonthVal, ., YearVal)
 
 --
 Dan Nelson
 [EMAIL PROTECTED]
 


-- 
-Mahmoud Badreddine

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



copying of information into a table from another with conditions (using where)

2005-03-17 Thread Mahmoud Badreddine
Hello,
I imported tow tables from an Access database to MySql.
Call them table1 and table2. 
 
Both tables came with unique identifiers (ID1 for table1 and ID2 for
table2)which were generated automatically as a regular integer
index(0,1,2...N-1) for an N set of data. I would like to get rid this
type of unique identifier.

I created a primary  key in table1 called mainID. I then created a
new column in table2 also called mainID which will contain the
information of the new primary key which I created.

I then issued the following mySql command:

update table2 set table2.mainID=table1.mainID where table2.ID1=table1.ID1;

I get the following error
ERROR 1054 (42S22): Unknown column 'ID1' in 'where clause'

Somehow  it doesn't recognize any columns from table1.


Your help is greatly apreciated...

Further explanation for my query:
My reasoning for the condition is : for each row in table2 with a
certain value for ID1, find the matching value in table1for ID1. Then
take the corresponding mainID value on that row and stick it in that
row in table2.
I hope that was enlightening rather than more confusing.

 



-- 
-Mahmoud Badreddine

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]