Re: [PHP] Code check please

2003-09-17 Thread CPT John W. Holmes
From: "James Johnson" <[EMAIL PROTECTED]>

> Can anyone see why this code isn't working
>
> $SID = $_SESSION['svUserID'];
> $AdID = $_GET['AdID'];
>
> // get the campuses assigned
> $qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID";

You say down below that this query only selects one row...

> $CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error());
> $row_CampusIDList = mysql_fetch_assoc($CampusIDList);

and this mysql_fetch_assoc() call will return that one row into
$row_CampusIDList.

> //var_dump($row_CampusIDList);
>
> $tmp = array();
> while( $rowData = mysql_fetch_array( $CampusIDList )) {

This while will never execute as there are no more rows to select.

> //print("ROW Data $rowData");
> if(!in_array($rowData['inst_id'],$tmp)){
>  $tmp[] = $rowData['inst_id'];
> }
> }
> //var_dump($tmp);
> $cidList = implode( ',', $tmp );
> //var_dump($cidList);
>
> If I do a var_dump($row_CampusIDList); I get a value, so I know there's
data
> to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're
> both empty.
>
> This particular value query only has 1 inst_id of 100. Other queries with
> one value (99,45, etc) will work.

---John Holmes...

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



RE: [PHP] Code check please

2003-09-17 Thread James Johnson
Hmm, ok I took out the 
$row_CampusIDList = mysql_fetch_assoc($CampusIDList); 

and it works But how come?

J

-Original Message-
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 17, 2003 9:17 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Code check please


Hi,

Can anyone see why this code isn't working

$SID = $_SESSION['svUserID'];
$AdID = $_GET['AdID'];

// get the campuses assigned
$qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID";
$CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error());
$row_CampusIDList = mysql_fetch_assoc($CampusIDList);
//var_dump($row_CampusIDList);

$tmp = array();
while( $rowData = mysql_fetch_array( $CampusIDList )) {
//print("ROW Data $rowData");
if(!in_array($rowData['inst_id'],$tmp)){
  $tmp[] = $rowData['inst_id'];
 }
}
//var_dump($tmp);
$cidList = implode( ',', $tmp );
//var_dump($cidList);

If I do a var_dump($row_CampusIDList); I get a value, so I know there's data
to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're
both empty.

This particular value query only has 1 inst_id of 100. Other queries with
one value (99,45, etc) will work.

Very strange...
Thanks,
James

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

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



Re: [PHP] Code check please

2001-06-21 Thread Robert Vetter



Andreas Skarin wrote:
> 
> I've tried to get this working for over an hour
> now, and it still won't. I don't even get an error
> message to help me find the problem so I was
> hoping that someone could check my code for me.
> 
> I'm fooling around with a basic form that is
> supposed to send one's name, surname and e-mail
> address to "receive.php". "receive.php" is then
> supposed to take the information and add it to a
> table called "tabell" in a database called
> "databas", but it doesn't work. I think there
> might be something wrong with my MySQL query.
> 
> - - - - - - - - - - - FORM - - - - - - - - - - - -
> - -
> 
> 
> Förnamn:
>  size="25">
> Efternamn:
>  size="25">
> E-mailadress:
>  size="25">
>  value="Log in">
> 
> 
> - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
> 
> - - - - - - - - - - - RECEIVE.PHP - - - - - - - -
> - - -
> 
>  
> // connection to MySQL
> $connection = mysql_connect("localhost",
> "username", "password");
> if (!$connection) {
> echo ("Unable to connect to the database
> server at this time." );
> exit();
> }
> 
> //select database
> if (! @mysql_select_db("databas") ) {
> echo ("Unable to locate the database at
> this time.");
> exit();
> }
> 
> // MySQL query
> $sql = "INSERT INTO tabell SET" .
> "fornamn ='$fornamn'," .
> "efternamn='$efternamn'," .
> "email='$email';";
> ?>

Hello,

and where is the mysql_query($sql) function call?

Robert

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Code check please

2001-06-21 Thread Warren Vail

It just occurred to me that one thing that will kill a query is special
query characters imbedded in your strings, like quotes (single or double).
This can be resolved by the

$resultstring = addslashes($sourcestring);

this should escape special characters normally used to signal key components
to the mysql query processor.

of course when you select the column you need to run it thru;

$resultstring = stripslashes($dbcolumnvalue);

to get back your original value.

good luck,

Warren Vail

-Original Message-
From: Andreas Skarin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 3:46 PM
To: PHP General
Subject: Re: [PHP] Code check please


I'm sorry guys, neither of the snippets work. I must have screwed something
else up
too. Is there any way I can provoke an error message from your code examples
below?
If anyone manages to find out what's wrong, please tell me. I'm not giving
up until
I smash this bug :-)

// Andreas

> Rich Cavanaugh wrote:
>
> > try:
> >
> > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values
('{$fornamn}',
> > '{$efternamn}', '{$email}')";
>
> Sebastian Wenleder wrote:
>
> > I'd use this SQL-query:
> >
> > $sql = "INSERT INTO tabell \
> > (fornamn,efternamn,email) \
> > VALUES(".$fornamn.", \
> > ".$efternamn.", ".$email.")";




--
Andreas Skarin
Svenska Dream Theater-Sällskapet
http://www.sdts.nu - mailto:[EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Code check please

2001-06-21 Thread Warren Vail

Andreas,

I'm not sure about code that appears to be missing like an execute query
function or checking the number of affected rows to make sure that the
insert worked, but clearly your insert code is not properly formed.  The
query could also be impacted by whether the columns are defined with special
attributes like DATE, etc.  Assuming that all columns are defined as
character strings the query should look like;

$sql = "INSERT INTO tabell (fornamn, efternamn, email) " .
"VALUES(\"$fornamn\", \"$efternamn\", \"$email\")";

I've found that I often have problems trying to use "single quotes" in sql
queries so I avoid them.  I notice that you also included a semi-colon in
the query text, while this works when piping a file of queries into the
mysql command, it does not work from a program.  The semi-colon in a command
stream into the mysql command actually signifies a point to stop and execute
the preceding text as a query and after executing that query, continue on
from the next character.

hope you got it working,

Warren Vail

-Original Message-
From: Andreas Skarin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 9:00 AM
To: PHP General
Subject: [PHP] Code check please


I've tried to get this working for over an hour
now, and it still won't. I don't even get an error
message to help me find the problem so I was
hoping that someone could check my code for me.

I'm fooling around with a basic form that is
supposed to send one's name, surname and e-mail
address to "receive.php". "receive.php" is then
supposed to take the information and add it to a
table called "tabell" in a database called
"databas", but it doesn't work. I think there
might be something wrong with my MySQL query.

- - - - - - - - - - - FORM - - - - - - - - - - - -
- -


Förnamn:

Efternamn:

E-mailadress:




- - - - - - - - - - - - - - - - - - - - - - - - -
- - -

- - - - - - - - - - - RECEIVE.PHP - - - - - - - -
- - -

Unable to connect to the database
server at this time." );
exit();
}

//select database
if (! @mysql_select_db("databas") ) {
echo ("Unable to locate the database at
this time.");
exit();
}

// MySQL query
$sql = "INSERT INTO tabell SET" .
"fornamn ='$fornamn'," .
"efternamn='$efternamn'," .
"email='$email';";
?>

- - - - - - - - - - - - - - - - - - - - - - - - -
- - -

Thanks in advance!

// Andreas


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code check please

2001-06-21 Thread Philip Olson

You want mysql_error(), call it somewhere after your query.

  echo mysql_error();

Regarding the query, the following should work just fine :

  $sql = "INSERT INTO tablefoo (a,b,c) VALUES ('$a','$b','$c')";

Be sure to add slashes sometime to your values beforehand. Anyway,
mysql_error() is what you're wanting.

  http://www.php.net/manual/function.mysql-error.php

regards,
philip


On Thu, 21 Jun 2001, Andreas Skarin wrote:

> I'm sorry guys, neither of the snippets work. I must have screwed something else up
> too. Is there any way I can provoke an error message from your code examples below?
> If anyone manages to find out what's wrong, please tell me. I'm not giving up until
> I smash this bug :-)
> 
> // Andreas
> 
> > Rich Cavanaugh wrote:
> >
> > > try:
> > >
> > > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}',
> > > '{$efternamn}', '{$email}')";
> >
> > Sebastian Wenleder wrote:
> >
> > > I'd use this SQL-query:
> > >
> > > $sql = "INSERT INTO tabell \
> > > (fornamn,efternamn,email) \
> > > VALUES(".$fornamn.", \
> > > ".$efternamn.", ".$email.")";
> 
> 
> 
> 
> --
> Andreas Skarin
> Svenska Dream Theater-Sällskapet
> http://www.sdts.nu - mailto:[EMAIL PROTECTED]
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Code check please

2001-06-21 Thread Peter Houchin - SunRentals Australia

what about just

$sql = "INSERT INTO tabell \
> > (fornamn,efternamn,email) \
> > VALUES("$fornamn", \
> > "$efternamn", "$email")";

??
-Original Message-
From: Andreas Skarin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 21, 2001 8:46 AM
To: PHP General
Subject: Re: [PHP] Code check please


I'm sorry guys, neither of the snippets work. I must have screwed something else up
too. Is there any way I can provoke an error message from your code examples below?
If anyone manages to find out what's wrong, please tell me. I'm not giving up until
I smash this bug :-)

// Andreas

> Rich Cavanaugh wrote:
>
> > try:
> >
> > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}',
> > '{$efternamn}', '{$email}')";
>
> Sebastian Wenleder wrote:
>
> > I'd use this SQL-query:
> >
> > $sql = "INSERT INTO tabell \
> > (fornamn,efternamn,email) \
> > VALUES(".$fornamn.", \
> > ".$efternamn.", ".$email.")";




--
Andreas Skarin
Svenska Dream Theater-Sällskapet
http://www.sdts.nu - mailto:[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Code check please

2001-06-20 Thread Jason Murray

> 2. Your SQL is a bit out of whack. The "SET" clause is used for
>UPDATEs, not INSERTs.
> 
>Instead, try:
> 
>$sql = "INSERT INTO tabell (fornamn, efternamn, email) VALUES (" .
>   "'$fornamn', '$efternamn', '$email');";

MySQL actually lets you use SET for INSERTS, though.

Jason

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code check please

2001-06-20 Thread Andreas Skarin

I'm sorry guys, neither of the snippets work. I must have screwed something else up
too. Is there any way I can provoke an error message from your code examples below?
If anyone manages to find out what's wrong, please tell me. I'm not giving up until
I smash this bug :-)

// Andreas

> Rich Cavanaugh wrote:
>
> > try:
> >
> > $sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}',
> > '{$efternamn}', '{$email}')";
>
> Sebastian Wenleder wrote:
>
> > I'd use this SQL-query:
> >
> > $sql = "INSERT INTO tabell \
> > (fornamn,efternamn,email) \
> > VALUES(".$fornamn.", \
> > ".$efternamn.", ".$email.")";




--
Andreas Skarin
Svenska Dream Theater-Sällskapet
http://www.sdts.nu - mailto:[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code check please

2001-06-20 Thread Lenar Lõhmus

UPDATE syntax for INSERT is allowed in MySQL, so that should not be the
problem as far as you include all fields not having default value, timestamp
type or auto_increment attribute in your statement. What's the error message
if there is any?

lenar

""Rich Cavanaugh"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> You're using UPDATE syntax for your INSERT
>
> try:
>
> $sql = "INSERT INTO tabell (fornamn, efternamn, email) values
('{$fornamn}',
> '{$efternamn}', '{$email}')";
>
> Rich Cavanaugh
>
> -Original Message-
> From: Andreas Skarin [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 20, 2001 12:00 PM
> To: PHP General
> Subject: [PHP] Code check please
>
>
> I've tried to get this working for over an hour
> now, and it still won't. I don't even get an error
> message to help me find the problem so I was
> hoping that someone could check my code for me.
>
> I'm fooling around with a basic form that is
> supposed to send one's name, surname and e-mail
> address to "receive.php". "receive.php" is then
> supposed to take the information and add it to a
> table called "tabell" in a database called
> "databas", but it doesn't work. I think there
> might be something wrong with my MySQL query.
>
> - - - - - - - - - - - FORM - - - - - - - - - - - -
> - -
>
> 
> Förnamn:
>  size="25">
> Efternamn:
>  size="25">
> E-mailadress:
>  size="25">
>  value="Log in">
> 
>
> - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
>
> - - - - - - - - - - - RECEIVE.PHP - - - - - - - -
> - - -
>
> 
> // connection to MySQL
> $connection = mysql_connect("localhost",
> "username", "password");
> if (!$connection) {
> echo ("Unable to connect to the database
> server at this time." );
> exit();
> }
>
> //select database
> if (! @mysql_select_db("databas") ) {
> echo ("Unable to locate the database at
> this time.");
> exit();
> }
>
> // MySQL query
> $sql = "INSERT INTO tabell SET" .
> "fornamn ='$fornamn'," .
> "efternamn='$efternamn'," .
> "email='$email';";
> ?>
>
> - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
>
> Thanks in advance!
>
> // Andreas
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code check please

2001-06-20 Thread Sebastian Wenleder

At 18:00 Uhr +0200 20.06.2001, Andreas Skarin wrote:
>I've tried to get this working for over an hour
>now, and it still won't. I don't even get an error
>message to help me find the problem so I was
>hoping that someone could check my code for me.

[snip]

>$sql = "INSERT INTO tabell SET" .
> "fornamn ='$fornamn'," .
> "efternamn='$efternamn'," .
> "email='$email';";
>

Hi Andreas

I'd use this SQL-query:

$sql = "INSERT INTO tabell \
(fornamn,efternamn,email) \
VALUES(".$fornamn.", \
".$efternamn.", ".$email.")";


Hope it works for you!

Best,
Sebastian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Code check please

2001-06-20 Thread Rich Cavanaugh

You're using UPDATE syntax for your INSERT

try:

$sql = "INSERT INTO tabell (fornamn, efternamn, email) values ('{$fornamn}',
'{$efternamn}', '{$email}')";

Rich Cavanaugh

-Original Message-
From: Andreas Skarin [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 20, 2001 12:00 PM
To: PHP General
Subject: [PHP] Code check please


I've tried to get this working for over an hour
now, and it still won't. I don't even get an error
message to help me find the problem so I was
hoping that someone could check my code for me.

I'm fooling around with a basic form that is
supposed to send one's name, surname and e-mail
address to "receive.php". "receive.php" is then
supposed to take the information and add it to a
table called "tabell" in a database called
"databas", but it doesn't work. I think there
might be something wrong with my MySQL query.

- - - - - - - - - - - FORM - - - - - - - - - - - -
- -


Förnamn:

Efternamn:

E-mailadress:




- - - - - - - - - - - - - - - - - - - - - - - - -
- - -

- - - - - - - - - - - RECEIVE.PHP - - - - - - - -
- - -

Unable to connect to the database
server at this time." );
exit();
}

//select database
if (! @mysql_select_db("databas") ) {
echo ("Unable to locate the database at
this time.");
exit();
}

// MySQL query
$sql = "INSERT INTO tabell SET" .
"fornamn ='$fornamn'," .
"efternamn='$efternamn'," .
"email='$email';";
?>

- - - - - - - - - - - - - - - - - - - - - - - - -
- - -

Thanks in advance!

// Andreas


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Code check please

2001-06-20 Thread J Smith


Your code is [mostly] fine, except for two things:

1. Although you connected to your database with mysql_connect() and
   mysql_select_db(), you didn't do anything with connection.

   Try using mysql_query() to send a query to the db, i.e.
mysql_query($sql).


2. Your SQL is a bit out of whack. The "SET" clause is used for
   UPDATEs, not INSERTs.

   Instead, try:

   $sql = "INSERT INTO tabell (fornamn, efternamn, email) VALUES (" .
  "'$fornamn', '$efternamn', '$email');";


Hope that works.

J



"Andreas Skarin" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I've tried to get this working for over an hour
> now, and it still won't. I don't even get an error
> message to help me find the problem so I was
> hoping that someone could check my code for me.
>
> I'm fooling around with a basic form that is
> supposed to send one's name, surname and e-mail
> address to "receive.php". "receive.php" is then
> supposed to take the information and add it to a
> table called "tabell" in a database called
> "databas", but it doesn't work. I think there
> might be something wrong with my MySQL query.
>
> - - - - - - - - - - - FORM - - - - - - - - - - - -
> - -
>
> 
> Förnamn:
>  size="25">
> Efternamn:
>  size="25">
> E-mailadress:
>  size="25">
>  value="Log in">
> 
>
> - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
>
> - - - - - - - - - - - RECEIVE.PHP - - - - - - - -
> - - -
>
> 
> // connection to MySQL
> $connection = mysql_connect("localhost",
> "username", "password");
> if (!$connection) {
> echo ("Unable to connect to the database
> server at this time." );
> exit();
> }
>
> //select database
> if (! @mysql_select_db("databas") ) {
> echo ("Unable to locate the database at
> this time.");
> exit();
> }
>
> // MySQL query
> $sql = "INSERT INTO tabell SET" .
> "fornamn ='$fornamn'," .
> "efternamn='$efternamn'," .
> "email='$email';";
> ?>
>
> - - - - - - - - - - - - - - - - - - - - - - - - -
> - - -
>
> Thanks in advance!
>
> // Andreas
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]