[PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread J. Connolly
Morning all,
I am having problems understanding what I need to do. Usually for most 
of my work, all i need to do is pull the information and place it like this:

function office_list(){
   global $link;
   echo tabletr;
   $sql = SELECT town
   FROM offices;
   $result = mysql_query($sql, $link);
   while ($array = mysql_fetch_array($result)){
   $office = $array['town'];
   $state = $array['state'];
   $zip = $array['zip'];
   echo td$office/td
   td$state/td
   td$zip/td;
   }
   echo /tr/table;
}
But now I need to separate the information in order to build a more 
complex table. I do not understand how to obtain each cell. I have a 
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try

$office = $array['town'][0]
I just get the first letter of that office. If someone could point me in 
the right direction I'd greatly appreciate it. I think I just do not 
know the terminology I am looking for. The PHP manual keeps brining me 
to pages that are not what I need.
Thank you,
jozef

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


Re: [PHP-DB] Sorting multidimensional arrays from mysql

2005-05-02 Thread J. Connolly
Thank you, That was the conceptual problem I was having.
jozef
Juffermans, Jos wrote:
In that case the best way is to read all the data at once. Something like
this:
// first read all the data
$sql = SELECT street, town, state, zip, phone FROM offices;
$result = mysql_query($sql, $link);
$all_data = array();
while ($this_row = mysql_fetch_array($result)){
array_push($all_data, $this_row);
}

// then create the HTML
echo table;
echo tr;
foreach ($all_data as $this_row) {
echo th . $this_row{town} . /th;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo td . $this_row{town} . /td;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo td . $this_row{street} . ,  .
$this_row{state} .   . $this_row{zip} . /td;
}
echo /tr;
echo tr;
foreach ($all_data as $this_row) {
echo tdPhone:  . $this_row{phone} . /td;
}
echo /tr;
echo /table;
Jos
PS: Please always reply to [EMAIL PROTECTED]
-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 16:14
To: Juffermans, Jos
Subject: Re: [PHP-DB] Sorting multidimensional arrays from mysql
I have the data which comes out like this from a select all statement
1, 1510 New State Highway (Rte. 44),Raynham, MA,2767
2,  646 Washington St., South Easton,MA,2375
3,   47 Broad St.,  Bridgewater, MA,2324
4,  605 Belmont St.,Brockton,MA,2301
5,  662 Main St.,   Falmouth,MA,2540

I need to be able to pull out certain cells when necessary and place 
them in a table. When I need to fetch one entire row, it is no problem. 
I just do not understand how to define each cell as unique. Perhaps this 
is not possible?

I need the data to be inputted something like:
th
Easton
/th
th
Raynham
/th
/tr
tr
td
646 Washinton Street
/td
td
1510 New State Highway (Rte.44)
/td
/tr
tr
td
South Easton, MA 02375
/td
td
Raynham, MA 02767
/td
/tr
tr
td
Phone:  (508) 238-8400
/td
td
Phone:  (508) 822-7444
/td
/tr
thanks,
jozef


Juffermans, Jos wrote:
 

mysql_fetch_array will always only return 1 row. $array['town'] won't be an
array but just a text and is therefor interpreted differently.
If you can give us more information (ie data model, output sample) we might
be able to help you a bit better.
Jos
-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: 02 May 2005 15:42
To: PHP list
Subject: [PHP-DB] Sorting multidimensional arrays from mysql
Morning all,
I am having problems understanding what I need to do. Usually for most 
of my work, all i need to do is pull the information and place it like
   

this:
 

function office_list(){
  global $link;
  echo tabletr;
  $sql = SELECT town
  FROM offices;
  $result = mysql_query($sql, $link);
  while ($array = mysql_fetch_array($result)){
  $office = $array['town'];
  $state = $array['state'];
  $zip = $array['zip'];
  echo td$office/td
  td$state/td
  td$zip/td;
  }
  echo /tr/table;
}
But now I need to separate the information in order to build a more 
complex table. I do not understand how to obtain each cell. I have a 
fixed number so it will never change.
I thought multidimensional arrays came as array[0][0], but when i try

$office = $array['town'][0]
I just get the first letter of that office. If someone could point me in 
the right direction I'd greatly appreciate it. I think I just do not 
know the terminology I am looking for. The PHP manual keeps brining me 
to pages that are not what I need.
Thank you,
jozef


   

 

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


[PHP-DB] xml, PHP, MYSQL

2005-04-05 Thread J. Connolly
I think i was dropped from the mailing list. So this message is twofold.
My second part is...
Is there a performance difference in returning a MySQL query in XML 
format? Is it a matter of preference whether the conversion takes place 
in php or mysql? I didn't even know mysql was capable of this until two 
days ago and I am having a difficult time putting the pieces together. I 
have already looked at the SimpleXML in php.net and the parsing 
functions as well.

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


Re: [PHP-DB] MySQL query problems...

2005-03-24 Thread J. Connolly
yeah...errora are important. I do not escape my quotation marks in a 
query. I use single quotes within my insert and select statements.
If it says No valis MySQL resource then you are returning 0 records 
which may be caused by escaping the quotations.

I follow this pattern
$sql =INSERT INTO table VALUES ('some value','another value','etc');
NIPP, SCOTT V (SBCSI) wrote:
I am getting errors for the following queries.  This query seems
to work fine in phpMyAdmin.
$query2 = SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, accounts
   WHERE AllMid_Data.CPU_IN_SVC = \Y\
   AND AllMid_Data.CPU_DNS = \sbcld.sbc.com\
   AND accounts.sbcuid = $sbcuid
   AND accounts.system = AllMid_Data.CPU_Hostname
   AND accounts.ctime IS NULL
   ORDER BY CPU_Hostname ASC;
$results2 = mysql_query($query2, $Prod) or die(mysql_error());
$system2 = mysql_fetch_assoc($results2);
$query3 = SELECT AllMid_Data.CPU_Hostname FROM AllMid_Data, acct_db
   WHERE AllMid_Data.CPU_IN_SVC = \Y\
   AND AllMid_Data.CPU_DNS = \sbcld.sbc.com\
   AND acct_db.key1 LIKE \$sbcuid%\
   AND acct_db.key1 LIKE \%\.AllMid_Data.CPU_Hostname
   ORDER BY CPU_Hostname ASC;
$results3 = mysql_query($query3, $Prod) or die(mysql_error());
$system3 = mysql_fetch_assoc($results3);
I am assuming that I have an issue with query3.  Thanks in
advance.
Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com
 

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


Re: [PHP-DB] global var

2005-03-15 Thread J. Connolly
you need to call the function
?
$txt = text;
function echo_txt()
{
global $txt;
echo $txt;
}
?

?php
echo_txt;
?
---
i got no signature,
jzf
Henk Jan Wils wrote:
sorry, thats the way i meant it...
i have it that way, but it doesnt work...
- Original Message - From: Bastien Koert 
[EMAIL PROTECTED]
To: [EMAIL PROTECTED]; php-db@lists.php.net
Sent: Tuesday, March 15, 2005 7:50 PM
Subject: RE: [PHP-DB] global var


no, that is not how it should be
?
$txt = text;
function echo_txt()
{
 global $txt;
 echo $txt;
}
?


From: H. J. Wils [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] global var
Date: Tue, 15 Mar 2005 18:38:13 +
Hi,
I want to use a global var, but it doesnt seem to work.
This how it should be right?
?
$txt = text;
function echo_txt()
{
  global $txt;
  echo $global;
}
?
but it doesnt work...
--
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] mysql_num_rows

2005-03-08 Thread J. Connolly
Use the mysql_error() function which may give you more answers. In 
addition you can use something like

$num = mysql_num_rows($test);
echo $num;
If it returns 0 you have no entries,  if nothing happens then you have 
problem with your query or connection. If you get a number then there is 
something else wrong. This is a test I haa to use to sort out some code. 
It is best if you use mysql_error() whenever possible during testing so 
that you can know exactly what goes wrong where. But I am a noob. There 
are probaly others with better answers.

Tsegaye Woldegebriel wrote:
Dear Sir or Madame,
I found the following error,
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result
resource in /home/xxx/public_html/sitename/dynamicfile.php on line 61
What is the reason?
I want anyone who knows to answer to reply me.
Thank you in advance for sharing your precious time.
 

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


[PHP-DB] Random Password problem

2005-03-08 Thread J. Connolly
I am using this php in order to create, store and send random passwords 
to people who want to join my mailing list.

?php
function random_password () {
$seed = (integer) md5(microtime());
mt_srand($seed);
$password = mt_rand(1,);
$password = substr(md5($password), 3,9);
return $password;
}
?
?php
$msg = random_password();
echo $msg;
?
I seem to be getting the same number very often which makes me fear that 
this is not so random. I am a noob so I do not know if this is 
coincidence or a fault in my coding.
Right now, I have been setting up passwords manually, but would like 
users to be as free from me as possible. Any direction would be helpful.

BTW, I keep getting the following number an absurd amount of times. I 
have deleted cookies and even gone to other machines, and yet it still 
generates this number.

8f31a3
Thank you,
jozef
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Notice: Undefined index: op

2005-02-22 Thread J. Connolly
I get the error message:
*Notice*: Undefined index: op
When trying to set up a form. I have looked everywhere for the solution. 
I don't understnadn how to define that index. The come it comes from is:

if ($_POST['op'] != 'ds') {
   $display_block = 
   form action=\$_SERVER[PHP_SELF]\ method=\POST\
   Your E-mail Address:
   input type=text name=\email\ size=40 maxlength=150/
  input type=radio name=\action\ value=\sub\ checked/subscribebr/
  input type=radio name=\action\ value=\unsub\ /unsubscribe
   input type=\hidden\ name=\op\ value=\ds\/
   input type=submit name=\submit\ value=\Submit Form\/
   /form;
}
I am trying to create a form which allows my users to join a mailing 
list. I conceptually understand what the problem is but cannot find out 
how to solve the problem. I cannot find out how to define 'op'. Please 
do not tell me to lower my error reporting levels. I would rather fix 
the problems. Thank you,
Joseph

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


Re: [PHP-DB] Notice: Undefined index: op

2005-02-22 Thread J. Connolly
Thank you everyone for your help. None of the solutions helped though. 
It is a long story, I have to use the undefined 'op' in a few places and 
all f the solution end up causing other error. But I appreciate the help 
and I understand when the problem is alot clearer.. I just turned off 
the error reporting like everyone suggested. Maybe when I learn a bit 
more I can go back and fix it. My application runs fine, I just like 
everything to be 'perfect'.
jzf


Martin Norland wrote:
J. Connolly wrote:
I get the error message:
*Notice*: Undefined index: op
When trying to set up a form. I have looked everywhere for the 
solution. I don't understnadn how to define that index. The come it 
comes from is:

if ($_POST['op'] != 'ds') {
   $display_block = 
   form action=\$_SERVER[PHP_SELF]\ method=\POST\
   Your E-mail Address:
   input type=text name=\email\ size=40 maxlength=150/
  input type=radio name=\action\ value=\sub\ 
checked/subscribebr/
  input type=radio name=\action\ value=\unsub\ /unsubscribe
   input type=\hidden\ name=\op\ value=\ds\/
   input type=submit name=\submit\ value=\Submit Form\/
   /form;
}

I am trying to create a form which allows my users to join a mailing 
list. I conceptually understand what the problem is but cannot find 
out how to solve the problem. I cannot find out how to define 'op'. 
Please do not tell me to lower my error reporting levels. I would 
rather fix the problems. Thank you,
Joseph
$_POST is likely empty, because the user requesting the page has 
likely not submitted the form (yet).  What you probably want (since 
you aren't going to lower the error reporting levels) is:

if ( isset($_POST['op'])  $_POST['op'] == 'ds' ) {
// do your operation here
} else {
// print your form/etc. here
}
You may want to use a different quoting style - I can't recall the 
name, but it's taken from perl

echo EOF
form action=$_SERVER[PHP_SELF] method=POST
...
the rest of your stuff, then on its own line right at the beginning of 
the line (no tabs/etc. :( )
...
EOF;

it basically echo's until it sees that delimiter, that could be EOD or 
STOP or whatever (well, there might be reserved words issues - I could 
more easily check if I could remember the name of the quoting style...)

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


[PHP-DB] referencing external functions

2005-02-15 Thread J. Connolly
Sorry if this is a duplicate. I accidentally sent to the listserve from 
the wrong address.

I am having trouble calling external functions. I am trying to use this 
to clean up the code in the display. I have this as the function.php

?php
function connect() {
global $link;
$link = mysql_connect(localhost,username,password)
  or die (Could not Connect to DB);
mysql_select_db(database,$link) or die (mysql_error());
}
function links() {
global $link;
$sql = select * from jozef_links;
$result = mysql_query($sql, $link) or die (mysql_error());
echo li;
while ($array = mysql_fetch_array($result)) {
  $id = $array['link_name'];
  $url= $array['link_url'];
  echo ula href=\$url\$id/a/ul\n;
}
echo /li;
}
?
and am trying to use it in this links3.php
?php
include('functions.php') or die (mysql_error());
?
but I keep getting the error message
*Warning*: main(1): failed to open stream: No such file or directory in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*
*Warning*: main(): Failed opening '1' for inclusion 
(include_path='.;c:\php4\pear') in 
*C:\Accounts\dbadream\wwwRoot\links3.php* on line *4*

Can anyone explain what is wrong. Both files are in the same directory 
and and both have the normal permissions set to access.
Thanks,
jzf

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


Re: [PHP-DB] referencing external functions

2005-02-15 Thread J. Connolly
Thanks Bastian,
I did not understand that require and include are not considered 
arguments. When i removed the parentheses everything was ok. I was also 
having a problem because my hosting company shut down my database for 
having too many connections...
jzf

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


Re: [PHP-DB] Cannot connect to local server

2005-02-10 Thread J. Connolly
Novice,
   This is rather complicated code. In addition you are making it over 
complicated by taking constants and just renaming them as other 
contants. This accomplished nothing. You would be better of just placing 
the information in the correct place. Otherwise you can make the 
arguments into variable such as:

$usr = 'masud';
Then,
mysqli_connect ($host, $usr, $pwd, $db)
In this case you could have a form which would allow users to access 
their own database and projects.
You do not need that if the statement unless you need an error or die 
message. (Which is standard and a good idea).
Google has alot of these answers
jzf

Novice Learner wrote:
Make sure that:
localhost is actually localhost
username is the actual authorized username of the database
the password is the actual password you have given for the user
the database is the actual database name you have given.
I am an absolute beginner and I have a file like this and works perfectly, 
although I had a lot of problems in the beginning, I use the following code:
// Set the database access information as constants.
define ('DB_USER', 'masud');//This is the actual user name
define ('DB_PASSWORD', 'mylove'); //This is the password
define ('DB_HOST', 'localhost'); //This is the localhost
define ('DB_NAME', 'masud'); //This is the actual database name
if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // Make the 
connnection.
Just my two cents.
Denis Gerasimov [EMAIL PROTECTED] wrote:
Hello,
I am trying to connect to MySQL using
$mysqli = new mysqli(example.com, user, pass, db);
And access is ALWAYS denied
(I played around changing user name/pass/host - didn't help me at all)
The thing is that I CAN connect to the db server using this user name and
password with my DB administration tool.
Some background
1. MySQL and Apache + PHP are running on the same machine.
2. The user is allowed to connect from '%' (everywhere)
3. Connecting to localhost fails too (saying cannot connect to socket...)
What is going on?
Best regards, Denis Gerasimov
Outsourcing Services Manager,
VEKOS, Ltd.
www.vekos.ru
 

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


[PHP-DB] empty set query

2005-02-08 Thread J. Connolly
I have a query which can result in an empty set/ no matching records. 
The code I have which returns a code is:

$result = mysqli_query($link, $sql);
   while ($query = mysqli_fetch_array($result)){
   $title = $query['title'];
   $director = $query['director'];
   echo tabletrtd$title/tdtd $director/td/tr/table\n;
 }
If the resulting query is a empty set, which variable or item to I 
refence as null.  I already tried
  
   if (!query) and (!$title)

and neither of them work. I also tried if either of them are null. I 
don't need someone to give me a long explanation just a small bump as to 
what I should be referencing. In other words, what is it that I should 
reference? Should I just write a code that returns number of rows  and 
use that?

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


Re: [PHP-DB] empty set query

2005-02-08 Thread J. Connolly
Thanks to you both Richard and Bastian. I am a newb and am trying to 
work alot out for myself. I decided to use the number rows method and 
validate against that. But now that I know that I should be defining my 
variables at the top, that will help alot.

jzf

Hutchins, Richard wrote:
Many ways to remove the epidermis from a feline, but...
You may want to do something equivalent (I think you're using mysqlite) to
the mysql_num_rows() function on your result set as a condition to running
your while loop . In pseudocode...
if(mysql_num_rows($result_set)  1){
echo out something like pno results/p.
}else{

your current while... loop  
}
That way, if your query returns no results, you don't try to set the
variables but you communicate that nothing was found.
Best way? Maybe not. I've used it a few times and it's done the trick for
me. Your mileage may vary.
Rich
-Original Message-
From: J. Connolly [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 08, 2005 1:23 PM
To: PHP list
Subject: [PHP-DB] empty set query
I have a query which can result in an empty set/ no matching records. 
The code I have which returns a code is:

$result = mysqli_query($link, $sql);
   while ($query = mysqli_fetch_array($result)){
   $title = $query['title'];
   $director = $query['director'];
   echo tabletrtd$title/tdtd $director/td/tr/table\n;
 }
If the resulting query is a empty set, which variable or item to I 
refence as null.  I already tried
  
   if (!query) and (!$title)

and neither of them work. I also tried if either of them are null. I 
don't need someone to give me a long explanation just a small bump as to 
what I should be referencing. In other words, what is it that I should 
reference? Should I just write a code that returns number of rows  and 
use that?

Jzf
 

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


[PHP-DB] MySQL PHP hosting

2005-02-08 Thread J. Connolly
Is there a site that someone could recommend that does PHP, Mysql 
hosting? If they do .NET that would be good also. This is for practice 
and development not for a company so I am looking to keep the costs 
down. There are so many sites, I thought maybe someone here might have a 
good solution.

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


Re: [PHP-DB] MySQL PHP hosting

2005-02-08 Thread J. Connolly
joe,
 thanks for the advicei just can't host where i work and trying to 
develop only on my laptop only at work is becoing tedious. The sys admin 
is not happy about me running iis or apache on my laptop here. But at 
least I didn't ask how you how to configure my php and mysql

richard,
 thanks for ipower that look kind of like what i am looking for
jozef

Joe Harman wrote:
Hey J.
I really like both of these companies
http://www.spinweb.net
http://www.rochen.com
both are big with PHP... both have top notch service and great
pricing... spinweb is great if you are into editing your confige
files...
Good Luck!
Joe
PS... people here on this board don't like these kinds of question..
just a FYI for you!
On Tue, 08 Feb 2005 16:07:47 -0500, J. Connolly [EMAIL PROTECTED] wrote:
 

Is there a site that someone could recommend that does PHP, Mysql
hosting? If they do .NET that would be good also. This is for practice
and development not for a company so I am looking to keep the costs
down. There are so many sites, I thought maybe someone here might have a
good solution.
jzf
--
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] Re: Newbie Setup Trouble

2005-02-07 Thread J. Connolly
Mike,
  There is no database sepcified in your code anywhere. The line:
   $result = mysql_query($sql); 
does not specify which database you are connecting to either. You can 
specify the database in the line:
   $link = 
mysql_connect($host,$user,$password,$database);//or in a separate 
line with the function
   mysql_select_db(database name,$link)//where $link 
is the connection info above
And then use  in the line:
   $result = mysql_query($link, $sql);   //this enable the 
query to find the connection and the code.

I hope this makes sense. I have only been doing this a couple of weeks. 
Some books have the ($link,$sql) order reversed which will also give you 
an error. IN ADDITION, if you are using mysqli you need to enter this 
ext in the PHP.ini file. I can only connect using mysqli and not mysql.
Good luck,
jzf

This should help you.
Mike Rondeau wrote:
  Hello,
 I have just begun study of using PHP, MySQL and Apache server. Right 
now I'm following a book, PHP and MySQL For Dummies and am having 
trouble already. I must be a REAL dummy! I have installed all 3 
programs but something is not right somewhere. Being so new to this I 
am having a real time trying to figure out which program is messed 
up. Certain things work, but others don't.

 For instance, my book told me how to make a phpinfo.php page, which 
works fine. But it also tells me to create some other pages to test 
if PHP and MySQL are working or not. I followed the scripts provided 
exactly but keep getting syntax errors, even though the script is 
just what the authors wrote. For instance, it said to make a page and 
call it mysql_up.php. Here's the script for it:

html
headtitleTest MySQL/title/head
body
!-- mysql_up.php --
?php
$host=localhost;
$user=blablablabla;
$password=blablabla;
mysql_connect($host,$user,$password);
$sql=show status;
$result = mysql_query($sql);
if ($result == 0)
{
   echo bError  . mysql_errno() . : 
 . mysql_error() . /b;
}
else
{
?
!-- Table that displays the results --
table border=1
  trtdbVariable_name/b/tdtdbValue/b
  /td/tr
  ?php
for ($i = 0; $i  mysql_num_rows($result); $i++) {
  echo TR;
  $row_array = mysql_fetch_row($result);
  for ($j = 0; $j  mysql_num_fields($result); $j++)
  {
echo TD . $row_array[$j] . /td;
  }
  echo /tr;
}
  ?
/table
?php } ?
/body/html

But when I open it in my browser I get this error:
Fatal error: Call to undefined function mysql_connect() in C:\Program 
Files\Apache Group\Apache2\htdocs\mysql_up.php on line 10

Could anyone of you smart people point me in the right direction? I'd 
be pulling my hair out if I had any left :)


 I can't make any progress with this study until I know my 3 programs 
are talking to eachother properly, but my book gives no info on this 
error.

 Thanks a millionfold for any advice, and I appologise for the length 
of this post.

Sincerely,
Mike Rondeau 

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


Re: [PHP-DB] Re: Newbie Setup Trouble

2005-02-07 Thread J. Connolly
To all, I am sorry the correct line is:
mysql_select_db($link,database name)
If you  are missing the database name you will get an error concerning  
undefined function.
jzf

J. Connolly wrote:
Mike,
  There is no database sepcified in your code anywhere. The line:
   $result = mysql_query($sql); does not specify which 
database you are connecting to either. You can specify the database in 
the line:
   $link = 
mysql_connect($host,$user,$password,$database);//or in a separate 
line with the function
   mysql_select_db(database name,$link)//where $link 
is the connection info above
And then use  in the line:
   $result = mysql_query($link, $sql);   //this enable the 
query to find the connection and the code.

I hope this makes sense. I have only been doing this a couple of 
weeks. Some books have the ($link,$sql) order reversed which will also 
give you an error. IN ADDITION, if you are using mysqli you need to 
enter this ext in the PHP.ini file. I can only connect using mysqli 
and not mysql.
Good luck,
jzf



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


[PHP-DB] Connecting To Mysql through php/mysqli

2005-02-02 Thread J. Connolly
I am getting the gollowing error message:
PHP Warning: mysqli_select_db() expects parameter 1 to be mysqli, string 
given in C:\Apache Group\Apache2\htdocs\PHP\_debug_tmp.php on line 5 PHP 
Fatal error: Call to undefined function mysqli_quesry() in C:\Apache 
Group\Apache2\htdocs\PHP\_debug_tmp.php on line 9

With the following code:
1?php
2//in order to connect
3$conn = mysqli_connect(localhost,root,67568);
4//inorder to designate database
5mysqli_select_db(php_example, $conn);
6
7//creating a table
8$sql = CREATE TABLE inventory (id int not null primary key 
auto_increment, item varchar(75));
9$result = mysqli_query($sql, $conn);
10echo $result;
11?

I am a total noob and am trying to copy this right out of a book (except 
the mysqli part which i had to struggle through on my own). I am using 
MySql 4.1.8 and PHP5 on Apache 2.0 server. Any help would be great.
Thank you,
jozef

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


RE: [PHP-DB] Connecting To Mysql through php/mysqli

2005-02-02 Thread J. Connolly
Thank you Bastian, I found that the two variables were reversed right 
when your answer came in. The book i got is horrible.

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