Re: [PHP-DB] Help needed creating a social network

2006-03-06 Thread Micah Stevens

CREATE TABLE `users` (userID int(11) not null auto_increment, primary 
key(userID), name tinytext not null, email tinytext not null);

CREATE TABLE `links` (userID int(11), key (userID), friendID int(11), 
key(friendID));

You have friends!!";
while ($f = mysql_fetch_assoc($friends)) {
echo "{$f['name']}\n";
}

publish();
profit($greatly);
do (!$use) {
coldfusion('Cause it sucks');
}
?>

(har har) 







On Monday 06 March 2006 9:47 pm, Daevid Vincent wrote:
> Anyone have some pointers at a HowTo on creating a social network?
>
> Basically I need to show people in your immediate network, and also friends
> of your friends, etc... Like the whole 'six degrees of separation' thing.
> Ala: myspace, friendster, etc. ad nauseum.
>
> I prefer mySQL and PHP, but I could port from most any code. I guess I'm
> mostly interested in the theory of this an how do I set up the tables
> properly and what is the magic incantation (JOIN) to get this "chain" of
> people.

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



[PHP-DB] Help needed creating a social network

2006-03-06 Thread Daevid Vincent
Anyone have some pointers at a HowTo on creating a social network?

Basically I need to show people in your immediate network, and also friends
of your friends, etc... Like the whole 'six degrees of separation' thing.
Ala: myspace, friendster, etc. ad nauseum.

I prefer mySQL and PHP, but I could port from most any code. I guess I'm
mostly interested in the theory of this an how do I set up the tables
properly and what is the magic incantation (JOIN) to get this "chain" of
people.

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



Re: [PHP-DB] Retricting Access to Menu Items

2006-03-06 Thread MIGUEL ANTONIO GUIRAO AGUILAR


Now that you mention it!!

I tried to use sessions but without success, i did:

session_start();
session_register(var);

but after log in as a different user, it keeps taking the data of the previous 
user. If I close the browser window and reload the page and log in, then it 
takes de current user

Maybe I'm not killing the previous session! session_unset();
Do I need to propagate the Session ID on every page that use session_start()??
Can I use session_id();?

Best Regards,
Miguel Guirao


- Mensaje original -
De: Jeffrey <[EMAIL PROTECTED]>
Fecha: Lunes, Marzo 6, 2006 7:37 ombr
Asunto: Re: [PHP-DB] Retricting Access to Menu Items

> I've done this kind of thing with a number of web apps.
> 
> What I usually do is create a user table in MySQL with a user-name, 
> password and access level, which has an integer value.
> 
> When a user logs in successfully, a session is created (see 
> session_start() in php documentation), the access level is pulled 
> from 
> the user table and saved as a session variable. Then it is a simple 
> matter of using bits of code like...
> 
> if ($_SESSION['access_level'] > 7){
>   echo "some stuff";
> }
> 
> In your example, you will also want to check the user's access 
> level on 
> each restricted page - it is not enough to hide menu options. Users 
> could simply type the URL in.
> 
> I hope that's clear.
> 
> Good luck,
> 
> Jeffrey
> 
> Jeff Broomall wrote:
> > Good morning everyone.
> > 
> > I'm building a very simple content management site that tracks 
> "tasks."> 
> > The options available are:
> >  1. Add Task
> >  2. Edit Task
> >  3. View Task
> >  4. Print Task
> > 
> > I need to restrict some users to only View and Print and I'm 
> trying to find a way to tell the page not to load the menu options 
> (the text) for those not having access to the Add and Edit functions.
> > 
> > IOW, they would only see View and Print.
> > 
> > I have three basic users:
> >  1. System Admin
> >  2. Subject Matter Expert (SME)
> >  3. Viewers
> > 
> > Obviously the System Admin and SME will have full access so it's 
> the Viewers that are to have access to only View and Print.
> > 
> > I have a users table but haven't set it up for the distinction.  
> What I was thinking was creating a field labeled users_group and 
> assign a numeric value for each user using the numbering system above.
> > 
> > I have my page load the menu options:
> > 
> > Home
> > View Tasks
> > Edit Task
> > Add Task
> > 
> > into here...
> > 
> > 
> > 
> >  align="center">> 
> >  ICAO Tasks — 
> WAFS>   
> >  
> > 
> >  Menu
> >   <--The menu above 
> inserted here.
> > 
> >  
> >  
> > 
> > 
> > How can I tell the system not to load the last two lines unless 
> they are a System Admin or SME?
> > 
> > I read a chapter on Cookies/Sessions...but it wasn't that helpful 
> for this case.
> > 
> > Can I setcookie('user_group', '3') and use that somehow???
> > 
> > Am I in the ballpark with this solution?
> > 
> > Thanks.
> > 
> > Jeff
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Este mensaje es exclusivamente para el uso de la persona o entidad a quien esta 
dirigido; contiene informacion estrictamente confidencial y legalmente 
protegida, cuya divulgacion es sancionada por la ley. Si el lector de este 
mensaje no es a quien esta dirigido, ni se trata del empleado o agente 
responsable de esta informacion, se le notifica por medio del presente, que su 
reproduccion y distribucion, esta estrictamente prohibida. Si Usted recibio 
este comunicado por error, favor de notificarlo inmediatamente al remitente y 
destruir el mensaje. Todas las opiniones contenidas en este mail son propias 
del autor del mensaje y no necesariamente coinciden con las de Radiomovil 
Dipsa, S.A. de C.V. o alguna de sus empresas controladas, controladoras, 
afiliadas y subsidiarias. Este mensaje intencionalmente no contiene acentos.

This message is for the sole use of the person or entity to whom it is being 
sent.  Therefore, it contains strictly confidential and legally protected 
material whose disclosure is subject to penalty by law.  If the person reading 
this message is not the one to whom it is being sent and/or is not an employee 
or the responsible agent for this information, this person is herein notified 
that any unauthorized dissemination, distribution or copying of the materials 
included in this facsimile is strictly prohibited.  If you received this 
document by mistake please notify  immediately to the subscriber and destroy 
the message. Any opinions contained in this e-mail are those of the author of 
the message and do not necessarily coincide with those of Radiomovil Dipsa, 
S.A. de C.V. or any of its control, controlled, affiliates and subsidiaries 
companies. No part of this message or attachments may be used or reproduced in 
any manner whatsoever.

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

[PHP-DB] Very Tricky PHP Array.

2006-03-06 Thread Michael Acs

Hi there,

I have one arrray: $field_vals
There are three values in the array, however two are multi-dimension array.

i.e:
$field_vals[base] -> Array (
[0] -> 1
[1] -> 2
)
$field_vals[make] -> Array (
[0] -> 5
[1] -> 7
[2] -> 8
)
$field_vals[qty] -> 1

I have a MySQL with a table (part) for the data to be stored in: part_id 
(key), base_id, make_id, qty

I need to build a series of MySQL queries to INSERT the data into the table.

ie.
INSERT INTO part(cols...) VALUES(1,5,1);
INSERT INTO part(cols...) VALUES(1,7,1);
INSERT INTO part(cols...) VALUES(1,8,1);
INSERT INTO part(cols...) VALUES(2,5,1);
INSERT INTO part(cols...) VALUES(2,7,1);

From the example array above, (2x3x1) 6 INSERT queries would be 
required. I would want this to be processed in the site form processor 
function. Basically, all my HTML forms have:
$field[table_column] <- which stores the field value or values in the 
case above.
$name[table_column] <- which stores the field name, this is always a 
single value since it is a hidden field.


The [table_column] corresponds to the exact column in the database. I 
also three additional values:

$table <- Mandatory, stores the table name.
$key <- Mandatory, stores the primary key column for the table.
$link <- Optional, however used if a entry is required to be added into 
another table that is related to the key in the primary table.


On submission, I use the $table value to list out all the columns that 
exist in the database table. Then I use a for() loop to go through each 
table column, which allows me to process both $field[table_column] and 
$field[table_column].


For me to be able to do a foreach() to achieve the list of queries I 
require to be executed in the database, I will most likely have to 
change the way I use the for loop, or will I? I am not exactly sure. My 
form processor code is quite long, however, I will place it at the 
bottom for reference.


What I could do is keep my first for() loop which outputs the submitted 
data on a confirmation page and create a separate section of the 
function altogether, which generates the queries I require. At the 
moment I generate a part of the MySQL queries inside the for loop, 
however, doesn't work quite as well when you have an array, rather then 
a single variable.


First of all, is it possible to do, if you do not want to static code to 
generate the queries?


This is how I would do it, if I used static code:

---CODE---

$db = mysql_connect();
$qty = $field_vals['qty'];
foreach ($field_vals['base'] as $base) {
   foreach ($field_vals['make'] as $make) {
  $inserts .= "($base, $make, $qty),";
   }
}
$sql = "INSERT INTO part(base, make, qty) VALUES " . substr($inserts, 0, 
-1);

if (mysql_query($sql, $db)) echo "done.";
else echo "error.";

-/-CODE-/-

I am not asking for people to completely rewrite my code, just some tips 
or hints on how to achieve this would be greatly appreciated.


Here is my current form processor function for reference, if you need 
any additional information, please let me know.


---CODE---

show_columns($table);
$count = count($columns);
// include validator configuration file
include('inc/validator.config.php');
// begin loop through each column
for ($i=0;$i<$count;$i++) {
// set variables
$column = $columns[$i];
$option = "";

// check that column exists in HMTL form
if ($fname[$column] || $fval[$column]) {
// begin row and set column value
$content .= "valign='top'>".$fname[$column].":";

$value = $fval[$column];
// validate column value
if (!is_array($value)) {
$fldmsg = validate($value,$db_col[$column]);
} else {
$fldmsg = "OK";
}
// if not table key
if ($column != $key) {
// set column field and table2 for drop down values
$selcolumn = ereg_replace($table."_","",$column);
$table2 = ereg_replace("_id","",$selcolumn);
// if drop down value
if (ereg("_id",$column) && !ereg("base_id",$column)) {
// grab table columns for drop down value
$columns2 = $db->show_columns($table2);
$lnkcolumn = 
ereg_replace($table2."_","",$columns2[2]);

// grab link column data
if (ereg("_id",$lnkcolumn)) {
$table3 = ereg_replace("_id","",$lnkcolumn);
if (!is_array($value)) {
$db->sql_query("SELECT * FROM $table2 
INNER JOIN $table3 ON $table2.".$table2."_$lnkcolumn = 
$table3.$lnkcolumn WHERE $table2.$selcolumn = '$value' LIMIT 1");

$data = $db->fetch_rows();
$option 

RE: [PHP-DB] Retricting Access to Menu Items

2006-03-06 Thread Bastien Koert

if you pull the user data into a session, then its a simple if them check


if ($_SESSION['user']['user_access']>1)  //1 = basic user
{
 echo 'Edit Task';
 echo 'Add Task';

}


bastien



From: "Jeff Broomall" <[EMAIL PROTECTED]>
To: 
Subject: [PHP-DB] Retricting Access to Menu Items
Date: Mon, 6 Mar 2006 07:27:03 -0500

Good morning everyone.

I'm building a very simple content management site that tracks "tasks."

The options available are:
 1. Add Task
 2. Edit Task
 3. View Task
 4. Print Task

I need to restrict some users to only View and Print and I'm trying to find 
a way to tell the page not to load the menu options (the text) for those 
not having access to the Add and Edit functions.


IOW, they would only see View and Print.

I have three basic users:
 1. System Admin
 2. Subject Matter Expert (SME)
 3. Viewers

Obviously the System Admin and SME will have full access so it's the 
Viewers that are to have access to only View and Print.


I have a users table but haven't set it up for the distinction.  What I was 
thinking was creating a field labeled users_group and assign a numeric 
value for each user using the numbering system above.


I have my page load the menu options:

Home
View Tasks
Edit Task
Add Task

into here...



align="center">


 ICAO Tasks — WAFS



 Menu
  <--The menu above inserted 
here.






How can I tell the system not to load the last two lines unless they are a 
System Admin or SME?


I read a chapter on Cookies/Sessions...but it wasn't that helpful for this 
case.


Can I setcookie('user_group', '3') and use that somehow???

Am I in the ballpark with this solution?

Thanks.

Jeff




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



RE: [PHP-DB] Re: PHP4 with MYSQL5

2006-03-06 Thread Bastien Koert
it does, you need the updated mysql library that comes with the php 5 files 
(libmysql.dll for windows)


bastien



From: João Cândido de Souza Neto <[EMAIL PROTECTED]>
To: php-db@lists.php.net,php-general@lists.php.net
Subject: [PHP-DB] Re: PHP4 with MYSQL5
Date: Mon, 06 Mar 2006 18:38:56 -0300

I receive aa answer by e-mail in order this telling me that i must upgrade
my php4 to php5.

It means that a php4 server don't works fine with mysql5 server?

João Cândido de Souza Neto wrote:

> Hello everyone.
>
> I'm trying to use my php4 conecting to a mysql5 server, and then 
executing

> some command lines to create a stored procedure but it's not working.
>
> When a tried to execute "delimiter |", my php gets de follow 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 'delimiter |'
> at line 1
>
> If I connect to server as local and try to execute the above command, it
> works fine.
>
> Could anyone help me about this? I'll be pleased by any tips.
>
> Thanks.

--
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] RE: [PHP] Re: PHP4 with MYSQL5

2006-03-06 Thread jblanchard
[snip]
I receive aa answer by e-mail in order this telling me that i must upgrade
my php4 to php5.

It means that a php4 server don't works fine with mysql5 server?
[/snip]

http://www.php.net/mysqli is designed to work with versions of MySQL 4.1.n and 
above. It requires PHP5

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



[PHP-DB] Re: PHP4 with MYSQL5

2006-03-06 Thread João Cândido de Souza Neto
I receive aa answer by e-mail in order this telling me that i must upgrade
my php4 to php5.

It means that a php4 server don't works fine with mysql5 server?

João Cândido de Souza Neto wrote:

> Hello everyone.
> 
> I'm trying to use my php4 conecting to a mysql5 server, and then executing
> some command lines to create a stored procedure but it's not working.
> 
> When a tried to execute "delimiter |", my php gets de follow 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 'delimiter |'
> at line 1
> 
> If I connect to server as local and try to execute the above command, it
> works fine.
> 
> Could anyone help me about this? I'll be pleased by any tips.
> 
> Thanks.

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



Re: [PHP-DB] Problem with a login page.

2006-03-06 Thread dpgirago

...

// check passwords match

$_POST['password'] = stripslashes($_POST['password']);
$info['password'] = stripslashes($info['password']);
$_POST['password'] = $_POST['password'];

if ($_POST['password'] != $info['password']) {
die('Incorrect password, please try again.');
}
...

Alex,

Sticking for the moment with the error message you get, I can't see
anyplace where an array named "$info" with a key of "password" is declared
or assigned this value. Are you sure that this variable exists?

David

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



[PHP-DB] Problem with a login page.

2006-03-06 Thread Alex Major
Hi there everyone, just wondered if you could help me with this login scipt.
I've tried to customise a script that I found on a website, but it dosn't
seem to be working.

Here is the scipt that isn't working.



Login




Logged in
Welcome back , you are logged in.


Login


Username:


Password:











I will also include the .php file incase the text above dosn't read well.
Basically, the page always returns 'Incorrect Password, please try again',
and I can't work out why. I've tried with two different accounts, and
neither are working. (I am 100% sure that I am entering usernames/passwords
correctly).

Thanks for any help with this, I can't for the life of me figure this out.

Regards, 
Alex. 




Login




Logged in
Welcome back , you are logged in.


Login


Username:


Password:










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

[PHP-DB] PHP4 with MYSQL5

2006-03-06 Thread João Cândido de Souza Neto
Hello everyone.

I'm trying to use my php4 conecting to a mysql5 server, and then executing
some command lines to create a stored procedure but it's not working.

When a tried to execute "delimiter |", my php gets de follow 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 'delimiter |' at
line 1

If I connect to server as local and try to execute the above command, it
works fine.

Could anyone help me about this? I'll be pleased by any tips.

Thanks.

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



[PHP-DB] Problems with PDO mysql

2006-03-06 Thread Escuder Nicolas
Hello,

 

I have made this little example for explain my problem : 

query("Update Test set data ='" . $data . "';");

?>

 

If i execute this scripts from php cli the result will be : 

/enabled=boolean:true;/description=string:"évènements"

 

If i execute this scripts from apache server the result will be : 

/enabled=boolean?;/description=string:"évènements"

 

It’s seem that is the é and è character that make this strange change
because if i remove this character the result will be :

/enabled=boolean:true;/description=string:"vnements"

 

I don’t found were the charset is converted or where is the problems ….

 

For information php cli and apache module are build with the same options.

 

I need help please.

 

I hope i ask my question in the good mailing list.

 

See You Soon.

 

Nicolas.

 



[PHP-DB] X Tiger 10.4.5 + phpBB2 + MySQL 5 + Can't Connect Issue! - SOLVED!

2006-03-06 Thread m i l e s

Hi,

Figured it out:

Apple wiped out the location of the socket.

they wanted '/var/mysql/mysql.sock'

it should be: '/tmp/mysql.sock'

Problem solved.

M i l e s.

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



Re: [PHP-DB] X Tiger 10.4.5 + phpBB2 + MySQL 5 + Can't Connect Issue!

2006-03-06 Thread Micah Stevens

Is there really a .sock file where you're telling php there is? MySQL can put 
the socket file anywhere you want depending on it's 
configuration. /etc/my.cnf should specify this. 

-Micah 


On Monday 06 March 2006 9:08 am, m i l e s wrote:
> Hi,
>
> Im getting the following: Warning: mysql_connect(): Can't connect to
> local MySQL server through socket...etc.
>
> NOTES:
>
> 1.) MySQL 5 is running fine.
> 2.) Im able to connect to it via Navicat.
> 3.) I run Lasso on the same host, I know that I can pull and post
> data to and from MySQL. So its NOT mysql. Its PHP.
>
> I ran across a few postings from Apple and others that had SIMILAR
> problems, however those solutions are for MySQL 4 not MySQL 5. Seems
> to be bit of confusion about how to solve this problem. I tried what
> apple suggested...and that FAILED:
>
> http://docs.info.apple.com/article.html?artnum=301457
>
> So now Im asking you good people, who actually BUILT the damn...ahem
> wrote the software. Im at whits end and I need to get this up and
> running.
>
> All I did was update from 10.4.4 to 10.4.5 and now PHP will not talk
> to MySQL at all. Ok...so what's the solution folks ? Anyone ?
> Buehler ? Buehler 
>
> Thanks ahead of time
>
> M i l e s.

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



[PHP-DB] X Tiger 10.4.5 + phpBB2 + MySQL 5 + Can't Connect Issue!

2006-03-06 Thread m i l e s

Hi,

Im getting the following: Warning: mysql_connect(): Can't connect to  
local MySQL server through socket...etc.


NOTES:

1.) MySQL 5 is running fine.
2.) Im able to connect to it via Navicat.
3.) I run Lasso on the same host, I know that I can pull and post  
data to and from MySQL. So its NOT mysql. Its PHP.


I ran across a few postings from Apple and others that had SIMILAR  
problems, however those solutions are for MySQL 4 not MySQL 5. Seems  
to be bit of confusion about how to solve this problem. I tried what  
apple suggested...and that FAILED:


http://docs.info.apple.com/article.html?artnum=301457

So now Im asking you good people, who actually BUILT the damn...ahem  
wrote the software. Im at whits end and I need to get this up and  
running.


All I did was update from 10.4.4 to 10.4.5 and now PHP will not talk  
to MySQL at all. Ok...so what's the solution folks ? Anyone ?  
Buehler ? Buehler 


Thanks ahead of time

M i l e s.

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



Re: [PHP-DB] Retricting Access to Menu Items

2006-03-06 Thread Jeffrey

I've done this kind of thing with a number of web apps.

What I usually do is create a user table in MySQL with a user-name, 
password and access level, which has an integer value.


When a user logs in successfully, a session is created (see 
session_start() in php documentation), the access level is pulled from 
the user table and saved as a session variable. Then it is a simple 
matter of using bits of code like...


if ($_SESSION['access_level'] > 7){
echo "some stuff";
}

In your example, you will also want to check the user's access level on 
each restricted page - it is not enough to hide menu options. Users 
could simply type the URL in.


I hope that's clear.

Good luck,

Jeffrey

Jeff Broomall wrote:

Good morning everyone.

I'm building a very simple content management site that tracks "tasks."

The options available are:
 1. Add Task
 2. Edit Task
 3. View Task
 4. Print Task

I need to restrict some users to only View and Print and I'm trying to find a 
way to tell the page not to load the menu options (the text) for those not 
having access to the Add and Edit functions.

IOW, they would only see View and Print.

I have three basic users:
 1. System Admin
 2. Subject Matter Expert (SME)
 3. Viewers

Obviously the System Admin and SME will have full access so it's the Viewers 
that are to have access to only View and Print.

I have a users table but haven't set it up for the distinction.  What I was 
thinking was creating a field labeled users_group and assign a numeric value 
for each user using the numbering system above.

I have my page load the menu options:

Home
View Tasks
Edit Task
Add Task

into here...





 ICAO Tasks — WAFS
  
 


 Menu
  <--The menu above inserted here.

 
 



How can I tell the system not to load the last two lines unless they are a 
System Admin or SME?

I read a chapter on Cookies/Sessions...but it wasn't that helpful for this case.

Can I setcookie('user_group', '3') and use that somehow???

Am I in the ballpark with this solution?

Thanks.

Jeff


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



[PHP-DB] Retricting Access to Menu Items

2006-03-06 Thread Jeff Broomall
Good morning everyone.

I'm building a very simple content management site that tracks "tasks."

The options available are:
 1. Add Task
 2. Edit Task
 3. View Task
 4. Print Task

I need to restrict some users to only View and Print and I'm trying to find a 
way to tell the page not to load the menu options (the text) for those not 
having access to the Add and Edit functions.

IOW, they would only see View and Print.

I have three basic users:
 1. System Admin
 2. Subject Matter Expert (SME)
 3. Viewers

Obviously the System Admin and SME will have full access so it's the Viewers 
that are to have access to only View and Print.

I have a users table but haven't set it up for the distinction.  What I was 
thinking was creating a field labeled users_group and assign a numeric value 
for each user using the numbering system above.

I have my page load the menu options:

Home
View Tasks
Edit Task
Add Task

into here...





 ICAO Tasks — WAFS
  
 

 Menu
  <--The menu above inserted here.

 
 


How can I tell the system not to load the last two lines unless they are a 
System Admin or SME?

I read a chapter on Cookies/Sessions...but it wasn't that helpful for this case.

Can I setcookie('user_group', '3') and use that somehow???

Am I in the ballpark with this solution?

Thanks.

Jeff