[PHP] Multiple MySQL INSERT

2008-12-01 Thread ddg2sailor

Hi People

My real problem is that I dont know code. I can sort of edit it in a sloppy
more or less works fashion. Any help would be great.

This is the code Im having problems with:


//Example//

$id = 0 + $_GET["id"];
$md5 = $_GET["secret"];




$gig = 1;
$giveupload = $gig*1024*1024*1024;

$res = mysql_query("SELECT passhash, editsecret, status FROM users WHERE id
= $id");
$row = mysql_fetch_array($res);



$res = mysql_query("SELECT passhash, editsecret, status FROM users WHERE id
= $id");
$row = mysql_fetch_array($res);


mysql_query("UPDATE users SET status='confirmed', uploaded = $giveupload ");

//send pm to new user

{

$msg = sqlesc("Hello and welcome to Cyber Drive In you have been
given a 1gb head start to help your ratio. .we are a strict but fair site
and our warning are based on the torrent ratio not the global just because
you have a good ratio dont mean you can hit and run if you do hit and run
your downloads maybe disabled even if your global ratio is fine..so enjoy
our free 1gb gift rules are seed what you take or for 72 hours..plz read the
rules and facts now you have joined our friendly community");
$added = sqlesc(get_date_time());
$subject = sqlesc("Welcome to Cyber Drive In");
mysql_query("INSERT INTO messages (sender, receiver, subject, msg,
added) VALUES (0, $id, $subject, $msg, $added)");


echo $SQL;
}


//end example//

This does confirm the user (without email , if you call it confirmed)
It does add 1gig to the new account.

However it dosent seem to want to insert into messages and by doing such
send a pm to the user defined in $id. I know this is very basic But a
friend of mine asked me to help him with his test site. Now I know a bit of
html and Im learning a bit of php as I go But the MySQL is like maertian
to me. :)

Sailor
-- 
View this message in context: 
http://www.nabble.com/Multiple-MySQL-INSERT-tp20786333p20786333.html
Sent from the PHP - General mailing list archive at Nabble.com.


Re: [PHP] Multiple MySQL INSERT

2008-12-01 Thread ddg2sailor


chris smith-9 wrote:
> 
> ddg2sailor wrote:
>> $row = mysql_fetch_array($res);
> 
>> $res = mysql_query("SELECT passhash, editsecret, status FROM users WHERE
>> id
>> = $id");
>> $row = mysql_fetch_array($res);
> 
> I hope this is a copy/paste error or are you running the same thing twice?
> 
> 
> I diddnt see that right away. In fact Im combining 2 pieces of code. The
> owner of this site dosent want to use a mail server and dosent want to do
> a manual confirm. So I added part of the confirm.php to the takesignup.php
> file
> 
>> mysql_query("UPDATE users SET status='confirmed', uploaded = $giveupload
>> ");
> 
> This updates *every* user to have a confirmed status. Probably not what 
> you want.
> 
> Add a
> 
> WHERE id='X';
> 
> clause
> 
> Believe me I agree with you... but this is how he wants it. It took me a
> while to realize that the new user cant call up the confirm.php without
> the mail with the link and the user name and secret word.
> 
>> //send pm to new user
>> 
>> {
>> 
>> $msg = sqlesc("Hello and welcome to Cyber Drive In you have been
>> given a 1gb head start to help your ratio. .we are a strict but fair site
>> and our warning are based on the torrent ratio not the global just
>> because
>> you have a good ratio dont mean you can hit and run if you do hit and run
>> your downloads maybe disabled even if your global ratio is fine..so enjoy
>> our free 1gb gift rules are seed what you take or for 72 hours..plz read
>> the
>> rules and facts now you have joined our friendly community");
>> $added = sqlesc(get_date_time());
>> $subject = sqlesc("Welcome to Cyber Drive In");
>> mysql_query("INSERT INTO messages (sender, receiver, subject,
>> msg,
>> added) VALUES (0, $id, $subject, $msg, $added)");
> 
> What is the sqlesc function?
> 
> This is the way the code is when I got it. I think that this is how it
> reads from the array. I can see where a table might be more use here.
> 
> You need quotes around your values:
> 
> $sql = "insert into table(f1, f2, f3) values ('" . 
> mysql_real_escape_string($value_1) . "', '" . 
> mysql_real_escape_string($value_2) . "')";
> 
> Im guessing that the preceding line got a bit chopped in the sending
> at least it dosent look quite right as it is. If I cut and paste this back
> together I should be able to follow your convention.
> 
> Thanks for your Reply... and if you saw the first post in this thread..
> sorry , shouldnt have clicked html and I should have previewed first.
> 
> Regards
> Sailor
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Multiple-MySQL-INSERT-tp20786333p20787487.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Multiple MySQL INSERT

2008-12-02 Thread ddg2sailor


chris smith-9 wrote:
> 
> ddg2sailor wrote:
>> 
> 
> 
>>It's still wrong regardless.
> 
> I dont run the system , However the code I didnt post checks to make sure
> the user name or email isnt already in use or in fact was in use but
> removed. Diddnt have to bother with that part , it works fine.
> 
>>User "A" signs up
>>User "B" signs up
> 
>>User "A" clicks the confirm link
> 
>>User "B" does not, but is confirmed anyway.
> 
>>> reads from the array. I can see where a table might be more use here.
> 
>>Eh? I asked about what the sqlesc function does - it is not a native php 
>>function.
> 
> I wish I could tell you more... but this isnt my code.  now it no doubt
> looks sloppy but It does work on anther system and sends the pm.  My
> thinking is more along the lines of getting the value for $id comming out
> to = ' ' (null) instead of the Username...
> 
> I havent been able yet to test the last edit of this code yet... It may
> even work. It runs on windows 2003 server sqlserver if this helps any.
> 
>>> You need quotes around your values:
>>>
>>> $sql = "insert into table(f1, f2, f3) values ('" . 
>>> mysql_real_escape_string($value_1) . "', '" . 
>>> mysql_real_escape_string($value_2) . "')";
>>>
>>> Im guessing that the preceding line got a bit chopped in the sending
>>> at least it dosent look quite right as it is. If I cut and paste this
>>> back
>>> together I should be able to follow your convention.
> 
>>No, I was just too lazy to use your code and instead I gave an example.
> 
> I diddnt expect you to do my work for me :) But thanks for the tip.
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Multiple-MySQL-INSERT-tp20786333p20805879.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

This is acctualy a very simple code... But I dont know exactly what to do
with line 18. It looks to be taking something from dox and redefining it as
RES. There is some related code but with syntax is pretty much has to be
this one.


//Example//


1024*1024)
  stderr( _("Error"), _("Sorry, you need to be a power user or higher to
download files larger than 1.00 MB.") );
  

$filename = sqlesc($filename);
$res = do_mysql_query("SELECT * FROM dox WHERE filename=$filename") or
sqlerr();
$arr = mysql_fetch_assoc($res);
if (!$arr)
stderr( _("Error"), _("File Not found"));
do_mysql_query("UPDATE LOW_PRIORITY dox SET hits=hits+1 WHERE id=$arr[id]")
or sqlerr();
$file = "$DOXPATH/$arr[filename]";
header("Content-Length: " . filesize($file));
header("Content-Type: application/octet-stream");
readfile($file);
?>

//end example//

this is line 18 :  $res = do_mysql_query("SELECT * FROM dox WHERE
filename=$filename") or sqlerr();

Any Help would be great.. Im lost here Near as I can tell this should be
legal.. but I not sure about hows its done.

Thanks
Sailor
-- 
View this message in context: 
http://www.nabble.com/syntax-error-%28stumped%29-tp20846197p20846197.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

Sorry , I did mean to mention that... But I forgot.

The original error is :

Fatal error: Call to undefined function do_mysql_query() in
C:\xampp\htdocs\getdox.php on line 18

Something to do with this //  or sqlerr();  //?

Thanks




Daniel P. Brown-2 wrote:
> 
> On Thu, Dec 4, 2008 at 8:32 PM, ddg2sailor <[EMAIL PROTECTED]> wrote:
>>
>> This is acctualy a very simple code... But I dont know exactly what to do
>> with line 18. It looks to be taking something from dox and redefining it
>> as
>> RES. There is some related code but with syntax is pretty much has to be
>> this one.
> [snip!]
>>
>> this is line 18 :  $res = do_mysql_query("SELECT * FROM dox WHERE
>> filename=$filename") or sqlerr();
> 
> What is the error?
> 
> There are a ton of things wrong and bad with that script example,
> but for now, is it a customized error output by a user function
> `sqlerr` that outputs a MySQL error, or is it saying that
> `do_mysql_query` isn't even defined?
> 
> -- 
> 
> http://www.parasane.net/
> [EMAIL PROTECTED] || [EMAIL PROTECTED]
> 50% Off Hosting! http://www.pilotpig.net/specials.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/syntax-error-%28stumped%29-tp20846197p20846336.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

I have been looking at this code all night and at one point I drew the same
conclusion. But I havent been able to find it Il beg the moderators
indulgence here.. But I really do need to add this code which calls the
other code as a user hits a link.

//dox.php//

 0)
stderr("Error", "A file with the title ", "".htmlspecialchars($title)."
already exists!");

$url = $_POST["url"];

if ($url != "")
if (substr($url, 0, 7) != "http://"; && substr($url, 0, 6) != "ftp://";)
stderr("Error", "The URL ", "" . htmlspecialchars($url) . " does not seem to
be valid.");

if (!move_uploaded_file($file["tmp_name"], "$DOXPATH/$file[name]"))
stderr("Error", "Failed to move uploaded file. You should contact an
administrator about this error.");

setcookie("doxurl", $url, 0x7fff);

$title = sqlesc($title);
$filename = sqlesc($file["name"]);

$uppedby = $CURUSER["id"];
$size = $file["size"];
$url = sqlesc($url);

mysql_query("INSERT INTO dox (title, filename, added, uppedby, size, url)
VALUES($title, $filename, NOW(), $uppedby, $size, $url)") or sqlerr();

header("Location: dox.php");
die;
}

//if (get_user_class() >= UC_MODERATOR || $a["uppedby"] == 
$CURUSER["id"])
//{
$delete = $HTTP_GET_VARS["delete"];
if (is_valid_id($delete))
{
$r = mysql_query("SELECT 
filename,uppedby FROM dox WHERE id=$delete")
or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($r) == 1)
{
$a = 
mysql_fetch_assoc($r);
if (get_user_class() >= 
UC_MODERATOR || $a["uppedby"] ==
$CURUSER["id"])
{

mysql_query("DELETE FROM dox WHERE id=$delete") or sqlerr(__FILE__,
__LINE__);
if 
(!unlink("$DOXPATH/$a[filename]"))

stderr("Warning", "Unable to unlink file:", "".$a['filename']." 
You should contact an administrator about this error.");
}
}
}
//}

stdhead("Dox");

//print(""._("Dox")."\n");
print("Dox\n");

$res = mysql_query("SELECT * FROM dox ORDER BY added DESC") or sqlerr();
if (mysql_num_rows($res) == 0)
print("Sorry, nothing here pal :(");
else
{
print("\n");
print("TitleDateTimeSizeHitsUpped
by\n");

$mod = get_user_class() >= UC_MODERATOR;

while ($arr = mysql_fetch_assoc($res))
{
$r = mysql_query("SELECT username FROM users WHERE id=$arr[uppedby]") or
sqlerr();
$a = mysql_fetch_assoc($r);
$FILELINK = $GLOBALS['DEFAULTBASEURL']."/getdox.php/".str_replace(" ","%20"
, $arr[filename]);
$title = " .$FILELINK. " . $arr[title] . " " .
($mod || $arr["uppedby"] == $CURUSER["id"] ? "  ?delete=$arr[id] [Delete] "
: "") ."\n";
$added = "" . substr($arr["added"], 0, 10) . "" .
substr($arr["added"], 10) . "\n";
$size = "" . mksize($arr['size']) . "\n";
$hits = "" . number_format($arr['hits']) . "\n";
$uppedby = " .$GLOBALS['DEFAULTBASEURL']. $a[username] \n";
print("$title$added$size$hits$uppedby\n");
}
print("\n");
print("Files are automatically deleted after 14 days...This is not in
place...\n");
}

if (get_user_class() >= UC_UPLOADER)
{
$url = $HTTP_COOKIE_VARS["doxurl"];
$maxfilesize = ini_get("upload_max_filesize");
begin_main_frame();
begin_frame("Upload", true);
print("\n");
print("\n");
print("File(Maximum file size: ".$maxfilesize.")\n");
print("Title(Optional, taken from file name if not
specified.)\n");


print("Download URL(Optional, specifies a primary FTP/HTTP download location.
You can substitute ".
"the file name part with an asterisk (*), e.g.
http://www.URSITE.com/files/*)&...\n");

print("\n");
print("\n");
print(&

Re: [PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

Its begining to look like this code was written for a newer sql

The sysop came up with an older php file that fixxed this issue Samples
enclosed.

//the file I been working on all days - relevant lines only"

$filename = sqlesc($filename);
$res = do_mysql_query("SELECT * FROM dox WHERE filename=$filename") or
sqlerr();
$arr = mysql_fetch_assoc($res);

//end

//The swapped out code that works - relevant lines only:

$filename = sqlesc($filename);
$res = mysql_query("SELECT * FROM dox WHERE filename=$filename") or
sqlerr();
$arr = mysql_fetch_assoc($res);

//end

Thats all she wrote... instead of do_mysql_query , mysql_query instead.
Thanks for all your help.. I do however have another issue.. but thats
another thread.

Sailor


chris smith-9 wrote:
> 
> ddg2sailor wrote:
>> I have been looking at this code all night and at one point I drew the
>> same
>> conclusion. But I havent been able to find it Il beg the moderators
>> indulgence here.. But I really do need to add this code which calls the
>> other code as a user hits a link.
> 
> Find the file where do_mysql_query is defined and include it.
> 
> It is not a native php function - someone made it up. Search your code 
> for the function.
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/syntax-error-%28stumped%29-tp20846197p20848455.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] error messaages - $DOXPath Wrong

2008-12-04 Thread ddg2sailor

Hi

Here are the error messages:

Warning: move_uploaded_file(C: mpp\htdocs\dox/th_dsc_076.jpg)
[function.move-uploaded-file]: failed to open stream: Invalid argument in
C:\xampp\htdocs\dox.php on line 40

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move
'C:\xampp\tmp\php2F.tmp' to 'C: mpp\htdocs\dox/th_dsc_076.jpg' in
C:\xampp\htdocs\dox.php on line 40

Warning: Cannot modify header information - headers already sent by (output
started at C:\xampp\htdocs\dox.php:40) in
C:\xampp\htdocs\include\bittorrent.php on line 478

Il make this as painless as possiable I know the third error can be
caused by a dangling white space.. this time it isnt.

This happens when a user uploads a 'dox file. Now we can download them all
we want.
The file Uploads to the right dir : 'C:\xampp\tmp\php2F.tmp' 
But when It tries to copy.. it tries to copy from this dir: C:
mpp\htdocs\dox/th_dsc_076.jpg
And tries to copy to this dir : 'C: mpp\htdocs\dox/th_dsc_076.jpg' 

the correct dirs are c:\xampp\tmp and c:\xampp\dox

//code that kicked my butt

 0)
stderr("Error", "A file with the title ", "".htmlspecialchars($title)."
already exists!");

$url = $_POST["url"];

if ($url != "")
if (substr($url, 0, 7) != "http://"; && substr($url, 0, 6) != "ftp://";)
stderr("Error", "The URL ", "" . htmlspecialchars($url) . " does not seem to
be valid.");

if (!move_uploaded_file($file["tmp_name"], "$DOXPATH/$file[name]"))
stderr("Error", "Failed to move uploaded file. You should contact an
administrator about this error.");

setcookie("doxurl", $url, 0x7fff);

$title = sqlesc($title);
$filename = sqlesc($file["name"]);

$uppedby = $CURUSER["id"];
$size = $file["size"];
$url = sqlesc($url);

mysql_query("INSERT INTO dox (title, filename, added, uppedby, size, url)
VALUES($title, $filename, NOW(), $uppedby, $size, $url)") or sqlerr();

header("Location: dox.php");
die;
}

//if (get_user_class() >= UC_MODERATOR || $a["uppedby"] == 
$CURUSER["id"])
//{
$delete = $HTTP_GET_VARS["delete"];
if (is_valid_id($delete))
{
$r = mysql_query("SELECT 
filename,uppedby FROM dox WHERE id=$delete")
or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($r) == 1)
{
$a = 
mysql_fetch_assoc($r);
if (get_user_class() >= 
UC_MODERATOR || $a["uppedby"] ==
$CURUSER["id"])
{

mysql_query("DELETE FROM dox WHERE id=$delete") or sqlerr(__FILE__,
__LINE__);
if 
(!unlink("$DOXPATH/$a[filename]"))

stderr("Warning", "Unable to unlink file:", "".$a['filename']." 
You should contact an administrator about this error.");
}
}
}
//}

stdhead("Dox");

//print(""._("Dox")."\n");
print("Dox\n");

$res = mysql_query("SELECT * FROM dox ORDER BY added DESC") or sqlerr();
if (mysql_num_rows($res) == 0)
print("Sorry, nothing here pal :(");
else
{
print("\n");
print("TitleDateTimeSizeHitsUpped
by\n");

$mod = get_user_class() >= UC_MODERATOR;

while ($arr = mysql_fetch_assoc($res))
{
$r = mysql_query("SELECT username FROM users WHERE id=$arr[uppedby]") or
sqlerr();
$a = mysql_fetch_assoc($r);
$FILELINK = $GLOBALS['DEFAULTBASEURL']."/getdox.php/".str_replace(" ","%20"
, $arr[filename]);
$title = " .$FILELINK. " . $arr[title] . " " .
($mod || $arr["uppedby"] == $CURUSER["id"] ? "  ?delete=$arr[id] [Delete] "
: "") ."\n";
$added = "" . substr($arr["added"], 0, 10) . "" .
substr($arr["added"], 10) . "\n";
$size = "" . mksize($arr['size']) . "\n";
$hits = "" . number_format($arr['hits']) . "\n";
$uppedby = " .$GLOBALS['DEFAULTBASEURL']. $a[username] \n";
print("$title$added$size$hits$uppedby\n");
}
print("\n");
print("Files are automatically deleted after 14 days...This is not in
place...\n");
}

if (get_user_class() >= UC_UPLOADER)
{
$url = $HTTP_COOKIE_VARS["doxurl"];
$maxfilesize = ini_get("upload_max_filesize");
begin_main_frame();
begin_frame("Upload", true);
print("\n");
print("\n");
print("File(Maximum file size: ".$maxfilesize.")\n");
print("Title(Optional, taken from file name if not
specified.)\n");

/*
print("Download URL(Optional, specifies a primary FTP/HTTP download location.
You can substitute ".
"the file name part with an asterisk (*), e.g.
http://www.URSITE.com/files/*)&...\n");
*/
print("\n");
print("\n");
print("\n");
end_frame();
end_main_frame();
}

stdfoot();
?>

//end

Sorr

Re: [PHP] error messaages - $DOXPath Wrong

2008-12-04 Thread ddg2sailor

This is line 40

if (!move_uploaded_file($file["tmp_name"], "$DOXPATH/$file[name]")) 

Sailor
-- 
View this message in context: 
http://www.nabble.com/error-messaages---%24DOXPath-Wrong-tp20848918p20848948.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] error messaages - $DOXPath Wrong

2008-12-05 Thread ddg2sailor

First I would like to thank everyone who reponded to this thread. Your all
Great!

I took your advice and made these changes

//Just the relevant lines not in order

$DOXPATH = 'C:\\xampp\\htdocs\\dox\\'

// New DOXPATH 


if (!move_uploaded_file($file['tmp_name'], '$DOXPATH\$file[name]'))

//Fixed line 40 (now 41) ' changed to ' , / change to \ , dont even think I
need that \


//end of code

I sent this code to the sysop of the site and it was in his mail box when he
decided to reformat the system and restore yet another backup. On the bright
side it did cure this issue But the file in question is now a java
script :) , I will never know if this worked cause its no longer used. I
fixxed a few minor error's that I had fixxed before the restore. I had to
check the php files because they were just slightly recoded... It took about
10 mins to fix what I already knew how to fix Now that everything
works... Im not important anymore... "Stop talking to me Im trying to do
some work"

Well who said life is supposed to be fair?




Maciek Sokolewicz-2 wrote:
> 
> Fix your definition of it (ie. use SINGLE quotes, or double escape it to 
> look like \\xa so the interpreter won't see it as a special escape 
> sequence anymore.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/error-messaages---%24DOXPath-Wrong-tp20848918p20867173.html
Sent from the PHP - General mailing list archive at Nabble.com.


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