Simple Machines Community Forum

General Community => Scripting Help => Topic started by: Doh004 on January 30, 2004, 10:22:53 PM

Title: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on January 30, 2004, 10:22:53 PM
Yea um my host did a repair of its server and somehow my mysql is all gone. My forums are gone, my download manager that i was making is gone, my guestbook, my hosted sites forums... Anything that had to do MYSQL.

I've contacted my host however is there anyway to get back my information? As of right now I'm really depressed from losing all the work that I put into it.

And I accept my stupidity for not making a backup of my mysql. The thought never occured to me :(
Title: Re: *starts crying* - Lost mysql
Post by: Chris Cromer on January 30, 2004, 11:14:34 PM
Sorry, but if there is no backup then there is no way to get the data back.
Title: Re: *starts crying* - Lost mysql
Post by: Tyris on January 31, 2004, 12:21:33 AM
chances are your host has a backup that might be a week or so old... but myeh...
its probably worth backing up your databases every week or so yourself...
Title: Re: *starts crying* - Lost mysql
Post by: Fizzy on January 31, 2004, 04:16:32 AM
Sorry to hear that Doh  :(

Depending on how big the DB is etc and what sort of Control Panel you have on the server you could run regular back ups puttng the file to the sites directory and every few days or so do a full backup download on to your PC.

Let's hope that the server host has a backup on file
Title: Re: *starts crying* - Lost mysql
Post by: Spaceman-Spiff on January 31, 2004, 05:23:36 AM
your host should've done backups before fixing/upgrading the server... :-\
hope they still have any backups that aren't old...
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 07:02:12 AM
Hehe yea uhhh well err...

Turns out its all okeydokey now. I just was a little PO'd and never thought that they would come back. But they did...

Now lets all just laugh at my stupidity and call it a day....
*hears laughter as doh walks away slowly*

;)
Title: Re: *starts crying* - Lost mysql
Post by: Fizzy on January 31, 2004, 02:28:51 PM
Glad to hear it's asll sorted Doh  ;D

I learned the same lesson thanks to a "practical joke" on YaBBSE - the less said about that the better  :-\
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 05:12:46 PM
Lol yep.
<?php
if (($_FILES['uploadedfile']['type'] == 'image/x-png') &&
($_FILES['uploadedfile']['size'] <= '50000'))
{
copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],
    $HTTP_POST_FILES['uploadedfile']['name']);

include (
"dbconnect.php");
$result = mysql_query('SELECT from roms_snes WHERE rom_id = '. $id);
$result2 = mysql_query('UPDATE roms_snes SET ss_1= '. $HTTP_POST_FILES['uploadedfile']['name'] .' WHERE rom_id = '. $id .');
}
else
{
echo '
Didn't work';
}
?>

Anyone see whats wrong with this code?

Thanks
Title: Re: *starts crying* - Lost mysql
Post by: morph on January 31, 2004, 05:21:51 PM
Quote from: Doh004 on January 31, 2004, 05:12:46 PM
Lol yep.
<?php
if (($_FILES['uploadedfile']['type'] == 'image/x-png') &&
($_FILES['uploadedfile']['size'] <= '50000'))
{
copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],
    $HTTP_POST_FILES['uploadedfile']['name']);

include (
"dbconnect.php");
$result = mysql_query('SELECT from roms_snes WHERE rom_id = '. $id);
$result2 = mysql_query('UPDATE roms_snes SET ss_1= '. $HTTP_POST_FILES['uploadedfile']['name'] .' WHERE rom_id = '. $id .');
?>

Anyone see whats wrong with this code?

Thanks

Yes... There is no closing }
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 05:23:39 PM
I saw that and it still doesnt work...
<?php
if (($_FILES['uploadedfile']['type'] == 'image/x-png') &&
($_FILES['uploadedfile']['size'] <= '50000'))
{
copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],
    $HTTP_POST_FILES['uploadedfile']['name']);

include (
"dbconnect.php");
$result = mysql_query('SELECT from roms_snes WHERE rom_id = '. $id);
$result2 = mysql_query('UPDATE roms_snes SET ss_1= '. $HTTP_POST_FILES['uploadedfile']['name'] .' WHERE rom_id = '. $id .');
}
?>
Title: Re: *starts crying* - Lost mysql
Post by: morph on January 31, 2004, 05:25:02 PM
well look at the following query's ...

$result = mysql_query('SELECT from roms_snes WHERE rom_id = '. $id);
$result2 = mysql_query('UPDATE roms_snes SET ss_1= '. $HTTP_POST_FILES['uploadedfile']['name'] .' WHERE rom_id = '. $id .');

I noticed how one has ' . $id); and the second has ' . $id . '); ... Could be a problem there?

edit.. dont forget to parse out the ' in don't..

else
{
echo 'Didn\'t work';
}
?>
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 05:29:05 PM
And I didnt have my password correct in my dbconnect.php ;)

umm. My script is supossed to add the url of the pic into the mysql...

I gotta look into that...
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 05:43:46 PM
Here's what i got and now its reading that theres a column with the uploaded files' name:
Unknown table 'png' in field list

heres what i have:
<?php
$default
= "news";
if(
$id == ""){$id = $default;}elseif(isset($id)){$id = $id;};

if ((
$_FILES['uploadedfile']['type'] == 'image/x-png') &&
($_FILES['uploadedfile']['size'] <= '50000'))
{
copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],
     $HTTP_POST_FILES['uploadedfile']['name']);

include (
"dbconnect.php");
$result = mysql_query('SELECT * FROM roms_snes WHERE rom_id = '.$id)
or die(mysql_error());
$result2 = mysql_query('UPDATE roms_snes SET ss_1= '. $HTTP_POST_FILES['uploadedfile']['name'] .' WHERE rom_id = '. $id)
or die(mysql_error());
}
?>
Title: Re: *starts crying* - Lost mysql
Post by: morph on January 31, 2004, 05:56:48 PM

<?php
global $HTTP_POST_FILES;
$default = "news";
if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;}

if (($_FILES['uploadedfile']['type'] == 'image/x-png') && ($_FILES['uploadedfile']['size'] <= '50000'))
{
copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],
     $HTTP_POST_FILES['uploadedfile']['name']);

include ("dbconnect.php");
$result = mysql_query("SELECT * FROM roms_snes WHERE rom_id = $id") or die(mysql_error());

while($row = mysql_fetch_assoc($result)) //could use mysql_fetch_array also.. right?
{
$result2 = mysql_query("UPDATE roms_snes SET ss_1= $HTTP_POST_FILES['uploadedfile']['name'] WHERE rom_id = $id") or die(mysql_error());
}
}
?>


Did you forget to add a global in there? also try this.. I played around with it. Also, it could be a SQL problem (no table name..)
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 06:28:24 PM
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/dohgames/public_html/roms/ss/savefile-snes.php on line 16

:-\
Title: Re: *starts crying* - Lost mysql
Post by: morph on January 31, 2004, 06:29:45 PM
Quote from: Doh004 on January 31, 2004, 06:28:24 PM
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/dohgames/public_html/roms/ss/savefile-snes.php on line 16

:-\


heh... whoops. Hm give me a few.

replace the second query with this..

$result2 = mysql_query("UPDATE roms_snes SET ss_1= $HTTP_POST_FILES[uploadedfile][name] WHERE rom_id = $id") or die(mysql_error());
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on January 31, 2004, 09:46:35 PM
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 '[name] WHERE rom_id = 1' at line 1
:'(
Title: Re: *starts crying* - Lost mysql
Post by: Doh004 on February 02, 2004, 07:33:34 AM
Please help anyone. *makes puppy dog face* ;)
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: morph on February 02, 2004, 09:21:36 PM
Hmpf... Sorry. Maybe I should work more with my php before trying to help  :-\
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on February 02, 2004, 10:28:53 PM
I'm gettign my else now:
<?php
$default
= "news";
if(
$id == ""){$id = $default;}elseif(isset($id)){$id = $id;}

if ((
$_FILES['uploadedfile']['type'] == 'image/x-png') && ($_FILES['uploadedfile']['size'] <= '50000'))
{
copy($HTTP_POST_FILES['uploadedfile']['tmp_name'],
   
$HTTP_POST_FILES['uploadedfile']['name']);

include ("dbconnect.php");
$result = mysql_query("SELECT * FROM roms_snes WHERE rom_id = $id") or die(mysql_error());
$result2 = mysql_query("UPDATE roms_snes SET ss_1=$HTTP_POST_FILES[uploadedfile][name] WHERE rom_id = $id") or die(mysql_error());
}
else
{
echo
'Hahaha didnt work';
}
?>
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: morph on February 03, 2004, 12:53:04 PM
Well then that means somewhere along the line, the if statement is not true... So what you should do to test this is put the following ABOVE the if statement.

echo $_FILES['uploadedfile']['type'];
echo $_FILES['uploadedfile']['size'];


See if it should be true.
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on February 03, 2004, 02:35:28 PM
Wait

I added '. .' and it worked. Cept now the pic that is dislplayed is this url: http://www.dohgames.com/roms/ss/.Array[name].

Thanks
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on February 03, 2004, 08:20:09 PM
edit* Nevermind I would like to thank the color coding on these forums for helping me out ;)
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Tyris on February 03, 2004, 08:41:16 PM
if you like colour coding, use a good php editor that does that ;)
I used notepad until I found dev-php (http://devphp.sourceforge.net) which is great :) (you can even hook it up to your php install and have it parse for errors).
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on February 03, 2004, 09:01:06 PM
Thanks for the link but i'm getting another parse error on line 54 that doesnt exist so i must be missing something. I need another pair of eyes to see it please:
<html>
<head>
<?php include("includes.php"); ?>
<title>
<?php echo"$title"; ?>
</title>
</head>
<body bgcolor="#4b4b4b" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<?php
$default
= "news";
if(
$id == ""){$id = $default;}elseif(isset($id)){$id = $id;};

include(
"dbconnect.php");

$result = mysql_query('SELECT * FROM roms_snes where rom_id = ' . $id)
or die(mysql_error());
while (
$row =  mysql_fetch_assoc($result))
{
echo
'<tr bgcolor="#333333"><td align="center" colspan="2" width="80%"><font size="2" face="verdana">';
echo
$row['name'];
echo
'</font></td></tr><tr bgcolor="#4b4b4b"><td width="45%" bgcolor="#333333" valign="top"><font size="1"face="verdana"><b>Name: </b>';
echo
$row['name'];
echo
'<br><br><b>File Size: </b>';
echo
$row['size'];
echo
' Kb<br><br><b>Downloads: </b>';
echo
$row['downloads'];
echo
'<br><br><b>System: </b>';
echo
$row['system'];
echo
'<br><br><b>Votes For: </b>';
echo
$row['rate_up'];
echo
'<br><br><b>Votes Against: </b>';
echo
$row['rate_down'];
echo
"<br><br><center><b>Rate this Rom</b><br><br><a href=\"rate_up.php?id=$id\"><img border=\"0\" src=\"http://www.dohgames.com/thup.gif\"></a> - <a href=\"rate_down.php?id=$id\"><img border=\"0\" src=\"http://www.dohgames.com/thudwn.gif\"></a></center></font></td><td bgcolor=\"#333333\" width=\"55%\" rowspan=\"2\"><center>";
if ( $row['ss_1'] != upload.png )
{
echo
'<img width="256" height="222" src="http://www.dohgames.com/roms/ss/';
echo
$row['ss_1'];
echo
'"></center></td></tr>';
}
else
{
echo
'<center><img src="http://www.dohgames.com/roms/ss/upload.png"></center><br>';
echo
"<center><font size\"1\" face=\"verdana\"><a href=\"http://www.dohgames.com/roms/ss/upload-snes.php?id=$id\">Upload a Screenshot</a></font></center></td></tr>";
echo
"<tr bgcolor=\"#333333\" width=\"80%\"><td><font size=\"1\" face=\"verdana\"><center><a href=\"download.php?id=$id\">Download ".$row["name"]."</a></center></font></td></tr>";
}
mysql_free_result($result);
?>
</table><br>
<font size="2" face="verdana"><center><a href="javascript:history.back(1)">Return to the Download Manager</a></center></font>
</body>
</html>
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Tyris on February 03, 2004, 09:19:04 PM
if($id == ""){$id = $default;}elseif(isset($id)){$id = $id;};

no ; on the end.

and the while doesnt close (thats why you're getting an error on a line that doesnt exist.)
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: morph on February 03, 2004, 09:20:28 PM
".$row["name"]."

should probably be

".$row['name']."

On line 53 (if I counted correctly.. could be 54... {we need line number in the code boxes :P})
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Tyris on February 03, 2004, 09:25:12 PM
heh... I didnt scroll across so I missed that bit... :-[
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on February 03, 2004, 09:26:46 PM
<html>
<head>
<?php include("includes.php"); ?>
<title>
<?php echo"$title"; ?>
</title>
</head>
<body bgcolor="#4b4b4b" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<?php
$default
= "news";
if(
$id == ""){$id = $default;}elseif(isset($id)){$id = $id;};

include(
"dbconnect.php");

$result = mysql_query('SELECT * FROM roms_snes where rom_id = ' . $id)
or die(mysql_error());
while (
$row =  mysql_fetch_assoc($result))
{
echo
'<tr bgcolor="#333333"><td align="center" colspan="2" width="80%"><font size="2" face="verdana">';
echo
$row['name'];
echo
'</font></td></tr><tr bgcolor="#4b4b4b"><td width="45%" bgcolor="#333333" valign="top"><font size="1"face="verdana"><b>Name: </b>';
echo
$row['name'];
echo
'<br><br><b>File Size: </b>';
echo
$row['size'];
echo
' Kb<br><br><b>Downloads: </b>';
echo
$row['downloads'];
echo
'<br><br><b>System: </b>';
echo
$row['system'];
echo
'<br><br><b>Votes For: </b>';
echo
$row['rate_up'];
echo
'<br><br><b>Votes Against: </b>';
echo
$row['rate_down'];
echo
"<br><br><center><b>Rate this Rom</b><br><br><a href=\"rate_up.php?id=$id\"><img border=\"0\" src=\"http://www.dohgames.com/thup.gif\"></a> - <a href=\"rate_down.php?id=$id\"><img border=\"0\" src=\"http://www.dohgames.com/thudwn.gif\"></a></center></font></td><td bgcolor=\"#333333\" width=\"55%\" rowspan=\"2\"><center>";
if ( $row['ss_1'] != upload.png )
{
echo
'<img width="256" height="222" src="http://www.dohgames.com/roms/ss/';
echo
$row['ss_1'];
echo
'"></center></td></tr>';
}
else
{
echo
'<center><img src="http://www.dohgames.com/roms/ss/upload.png"></center><br>';
echo
"<center><font size\"1\" face=\"verdana\"><a href=\"http://www.dohgames.com/roms/ss/upload-snes.php?id=$id\">Upload a Screenshot</a></font></center></td></tr>";
echo
"<tr bgcolor=\"#333333\" width=\"80%\"><td><font size=\"1\" face=\"verdana\"><center><a href=\"download.php?id=$id\">Download ".$row["name"]."</a></center></font></td></tr>";
}
mysql_free_result($result);
}
?>
</table><br>
<font size="2" face="verdana"><center><a href="javascript:history.back(1)">Return to the Download Manager</a></center></font>
</body>
</html>

and I get this above: Warning: mysql_fetch_assoc(): 5 is not a valid MySQL result resource in /home/dohgames/public_html/roms/snes/view.php on line 18
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Tyris on February 03, 2004, 09:54:37 PM
you're clearing the result before you're getting thru it...

mysql_free_result($result);
}

replace with

}
mysql_free_result($result);
Title: Re: Adding pic into mysql *updated 2/2/04
Post by: Doh004 on February 04, 2004, 05:35:39 PM
Thanks and I gots another problem. For some reason the a href of the upload-snes.php file that I want to be over the image that says upload a screenshot isnt working:
<html>
<head>
<?php include("includes.php"); ?>
<title>
<?php echo"$title"; ?>
</title>
</head>
<body bgcolor="#4b4b4b" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table width="100%" border="0" cellpadding="3" cellspacing="3">
<?php
$default
= "news";
if(
$id == ""){$id = $default;}elseif(isset($id)){$id = $id;};

include(
"dbconnect.php");

$result = mysql_query('SELECT * FROM roms_snes where rom_id = ' . $id)
or die(mysql_error());
while (
$row =  mysql_fetch_assoc($result))
{
echo
'<tr bgcolor="#333333"><td align="center" colspan="2" width="80%"><font size="2" face="verdana">';
echo
$row['name'];
echo
'</font></td></tr><tr bgcolor="#4b4b4b"><td width="45%" bgcolor="#333333" valign="top"><font size="1"face="verdana"><b>Name: </b>';
echo
$row['name'];
echo
'<br><br><b>File Size: </b>';
echo
$row['size'];
echo
' Kb<br><br><b>Downloads: </b>';
echo
$row['downloads'];
echo
'<br><br><b>System: </b>';
echo
$row['system'];
echo
'<br><br><b>Votes For: </b>';
echo
$row['rate_up'];
echo
'<br><br><b>Votes Against: </b>';
echo
$row['rate_down'];
echo
"<br><br><center><b>Rate this Rom</b><br><br><a href=\"rate_up.php?id=$id\"><img border=\"0\" src=\"http://www.dohgames.com/thup.gif\"></a> - <a href=\"rate_down.php?id=$id\"><img border=\"0\" src=\"http://www.dohgames.com/thudwn.gif\"></a></center></font></td><td bgcolor=\"#333333\" width=\"55%\" rowspan=\"2\"><center>";
if ( ($row['ss_1'] != upload.png) )
{
echo
'<img width="256" height="222" src="http://www.dohgames.com/roms/ss/';
echo
$row['ss_1'];
echo
'"></center></td></tr>';
}
else
{
echo
"<a href=\"http://www.dohgames.com/roms/ss/upload-snes.php?id=$id\"><img src=\"http://www.dohgames.com/roms/ss/upload.png\"></a><br>";
}
echo
"<tr bgcolor=\"#333333\" width=\"80%\"><td><font size=\"1\" face=\"verdana\"><center><a href=\"download.php?id=$id\">Download ".$row["name"]."</a></center></font></td></tr>";
}
mysql_free_result($result);
?>
</table><br>
<font size="2" face="verdana"><center><a href="javascript:history.back(1)">Return to the Download Manager</a></center></font>
</body>
</html>

I'm just not getting a link..