Immortal55
-
Posts
59 -
Joined
-
Last visited
Never
Posts posted by Immortal55
-
-
When I click the 'next' link nothing changes except the value of rowstart in the URL bar.
What is wrong?:
[code]
if (!$rowstart) $rowstart = 0;
$sql = mysql_query("SELECT * FROM user_art where user = '{$_REQUEST['user']}' and catagory = '{$_REQUEST['cid']}' order by id desc limit 15") or die(mysql_error());
$sql2 = mysql_query("SELECT * FROM user_art where user = '{$_REQUEST['user']}' and catagory = '{$_REQUEST['cid']}'") or die(mysql_error());
$numrows = mysql_num_rows($sql2);
//the above line would get all your users, and order them by their Id's
// the loop below would then make a link for every user
while($row = mysql_fetch_array($sql))
{
stripslashes($row);
$id = $row['id'];
if($HTTP_SESSION_VARS['valid_user'] == $_REQUEST['user'])
{ echo "<a href='picturefull.php?id=$id'>" . $row['title'] . "</a> - " . $row['description'] . " ";
echo " - [<a href='updateart.php?id=$id'>edit</a>] [<a href='deleteart.php?id=$id'>delete</a>]<br><br>";
}else {
echo "<a href='picturefull.php?id=$id'>" . $row['title'] . "</a> - " . $row['description'] . "<br>"; }
}
echo "<br><br>";
if ($rowstart != 0) {
echo "<a href='$PHP_SELF?user=".$_REQUEST['user']."&cid=".$_REQUEST['cid']."&rowstart=".($rowstart - 15)."'>Last 15</a>";
}
if (($rowstart + 15) < $numrows) {
echo "<a href='$PHP_SELF?user=".$_REQUEST['user']."&cid=".$_REQUEST['cid']."&rowstart=".($rowstart + 15)."'>Next 15</a>";
}
?>
[/code] -
Would it be possible to resize an image to fit a page temporarily? So if an image is uploaded, and its dimensions are large, I can just do
<img src="image.jpg" width="PHPcreateddimension" height="PHPcreateddimension">
Is this possible? I do not want to have to create a new image I just want it to size the image. -
I'm sorry, but I really need help with this.
-
alright, i messed with the script, and its still not working it dosent show the id, hence its not doing the query..... this is the new updated one:
[code]
<?php
// code that will be executed if the form has been submitted:
if ($submit) {
// connect to the database
require_once('dbconnect.php');
$conn = db_connect();
mysql_select_db("user_art");
$updir = "art/";
$finame = $_FILES['form_data']['name'];
$path = $updir.$finame;
move_uploaded_file($_FILES['form_data']['tmp_name'], $path)
or die('Could not move the file <br> ' . $_FILES['form_data']['error'] .' '); // Good to have error checking.
$descript = $_POST['form_description'];
$fisize = $_FILES['form_data']['size'];
$fitype = $_FILES['form_data']['type'];
$result = mysql_query("INSERT INTO user_art (description, path, filename, filesize, filetype)
VALUES ('" . $descript . "', '" . $path . "', '" . $finame . "', '" . $fisize . "', '" . $fitype . "')");
if($result) {
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
}
mysql_close();
} else {
// else show the form to submit new data:
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
[/code]
what is wrong now? -
alright, well i changed everything so the $_FILES has ['form_data'] before the attribute.....but all that the $_FILES['form_data']['error'] gave me was '0' thats it....does that mean anything?
-
Alright, something is wrong with this script and I cannot figure it out, I just get the 'Could no move File' Error that I wrote myself....
[code]
<?php
// code that will be executed if the form has been submitted:
if ($submit) {
// connect to the database
require_once('dbconnect.php');
$conn = db_connect();
mysql_select_db("user_art");
move_uploaded_file("'" . $_FILES['form_data'] . "'", "art/" . $_FILES['name'] . " ")
or die('Could not move the file'); // Good to have error checking.
$path = "art/" . $_FILES['name'] . " ";
mysql_query("INSERT INTO user_art (description, path, filename, filesize, filetype)
VALUES ('" . $_POST['form_description'] . "', '$path', '" . $_FILES['name'] . "','" . $_FILES['size'] . "','" . $_FILES['type'] . "')");
$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
mysql_close();
} else {
// else show the form to submit new data:
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
File Description:<br>
<input type="text" name="form_description" size="40">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br>File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
[/code]
thank you in advance. -
Alright, how in the world can I do this:
uploadforms.php - A form where you simply input a title, choose a file to upload, add a comment for the file, and select a catagory for the file. All of this info is then passed onto upload.php
upload.php - this takes the info from the forms puts it in a database, I know how to get all the text into the database, but how can i store the file location of the file in the DB (the location of the file on the server)? I cannot seem to get this, and I have been at it for weeks.... -
i still cannot get it, does anybody have any ideas?
-
alright, i added all that but now i am getting this warning:
[b]
Warning: copy(h): failed to open stream: No such file or directory in /home/.diddle/studiocommunity/studiocommunity.net/artupload.php on line 102[/b] -
anyone? help, please.
-
I am working on a gallery, I got it from a tutorial, and i am tweaking it but after i select my photos and press the submit button it just sits there loading and nothing happens and then i get this error message:
Fatal error: Maximum execution time of 30 seconds exceeded in /home/.diddle/studiocommunity/studiocommunity.net/artupload.php on line 65
here are the scripts
artuploadforms.php:
[code]
<?
include 'image.dbconnect.php';
// initialization
$photo_upload_fields = '';
$counter = 1;
// If we want more fields, then use, preupload.php?number_of_fields=20
$number_of_fields = (isset($_GET['number_of_fields'])) ?
(int)($_GET['number_of_fields']) : 5;
// Firstly Lets build the Category List
$result = mysql_query('SELECT category_id,category_name FROM art_category');
while($row = mysql_fetch_array($result)) {
$photo_category_list .= <<<__HTML_END
<option value="$row">$row</option>\n
__HTML_END;
}
mysql_free_result($result);
// Lets build the Image Uploading fields
while($counter <= $number_of_fields) {
$photo_upload_fields .= <<<__HTML_END
<tr><td>
Photo {$counter}:
<input name="photo_filename"
type="file" />
</td></tr>
<tr><td>
Caption:
<textarea name="photo_caption" cols="30"
rows="1"></textarea>
</td></tr>
__HTML_END;
$counter++;
}
// Final Output
echo <<<__HTML_END
<html>
<head>
<title>Lets upload Photos</title>
</head>
<body>
<form enctype="multipart/form-data"
action="artupload.php" method="post"
name="upload_form">
<table width="90%" border="0"
align="center" style="width: 90%;">
<tr><td>
Select Category
<select name="category">
$photo_category_list
</select>
</td></tr>
<!—Insert the image fields here -->
$photo_upload_fields
<tr><td>
<input type="submit" name="submit"
value="Add Photos" />
</td></tr>
</table>
</form>
</body>
</html>
__HTML_END;
?>
[/code]
and artupload.php
[code]
<?
include ('image.dbconnect.php');
// Fetch the image array sent by preupload.php
$photos_uploaded = $_FILES['photo_filename'];
// Fetch the image caption array
$photo_captions = $_POST['photo_captions'];
$photo_types = array(
'image/pjpeg' => 'jpg',
'image/jpeg' => 'jpg',
'image/gif' => 'gif',
'image/bmp' => 'bmp',
'image/x-png' => 'png'
);
while($counter <= count($photos_uploaded)) {
if($photos_uploaded['size'][$counter] > 0) {
if(!array_key_exists($photos_uploaded['type'][$counter], $photo_types)) {
$result_final .= 'File ' . ($counter + 1) .
' is not a photo<br />';
} else {
// Great the file is an image, we will add this file
}
}
}
mysql_query("
INSERT INTO art_photos
(photo_filename, photo_caption, photo_category) VALUES
('0', '" . $photo_captions[$counter]) . "', '" . $_POST['category'] . "')'";
$new_id = mysql_insert_id(); // New Id generated
// Get the filetype of the uploaded file
$filetype = $photos_uploaded['type'][$counter];
// Get the extension for the new name
$extension = $known_photo_types[$filetype];
// Generate a new name
$filename = "$new_id.$extension";
// let’s update the filename now
mysql_query("
UPDATE gallery_photos SET
photo_filename = '$filename'
WHERE photo_id = '$new_id'
");
copy($photos_uploaded['tmp_name'][$counter],
$images_dir . '/' . $filename);
move_uploaded_file($photos_uploaded['tmp_name'][$counter],
$images_dir . '/' . $filename);
?>
[/code]
what is wrong?? thank you. -
ah wow, that helped a lot, thank you!
-
[code]
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","user","password");
//select which database you want to edit
mysql_select_db("spoono_news");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("select * from news order by id");
//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the news
$title=$r["title"];//take out the title
$id=$r["id"];//take out the id
//make the title a link
echo "<a href='edit.php?cmd=edit&id=$id'>$title - Edit</a>";
echo "<br>";
}
}
?>
[/code]
[code]
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM news WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="edit.php" method="post">
<input type=hidden name="id" value="<?php echo $myrow["id"] ?>">
Title:<INPUT TYPE="TEXT" NAME="title" VALUE="<?php echo $myrow["title"] ?>" SIZE=30><br>
Message:<TEXTAREA NAME="message" ROWS=10 COLS=30><? echo $myrow["message"] ?></TEXTAREA><br>
Who:<INPUT TYPE="TEXT" NAME="who" VALUE="<?php echo $myrow["who"] ?>" SIZE=30><br>
<input type="hidden" name="cmd" value="edit">
<input type="submit" name="submit" value="submit">
</form>
<? } ?>
[/code]
what is $cmd representing there? I could not understand it (this was in a tutorial) -
is the $cmd variable already stated by php? if so what exactly is it doing?
-
Hmmm, alright, Yeah my idea did not work....Can anyone look over my scripts again and see if they cant find out what is wrong?
-
I realized that I was not populating my $_REQUEST like I thought I was. The link to the edit was just writingforms.php, not writingforms.php?id=. I think that was my problem, although I cannot try it right now. Would you reccoment I get rid of the $w array and just use the $row function?
-
When A user clicks on an edit link for a certain story in profile.php, it takes them to writingforms.php. When writing forms is loaded I want it to load in the info from the DB into the text fields and you can edit it that way. The fields are not loading the info into them how come?
profile.php code snippet:
[code]
<? //journal call
$db = mysql_select_db('studiocommunity', $conn)
or die("Unable to access user information in database, try again later.");
$sql = mysql_query('select * from user_writings where user = "' . $_REQUEST['user'] . '"order by id desc') or die(mysql_error());
while($row = mysql_fetch_assoc($sql)) {
stripslashes(extract($row));
echo "<a href='writings.php?id=$id'>" . $title . " - " . date("F d, Y", $date) . "</a> ";
if($HTTP_SESSION_VARS['valid_user'] == $_REQUEST['user'])
{ echo " - [<a href='writingforms.php'>edit</a>] [delete]<br>";
}
}
?>
[/code]
and writingforms.php
[code]
<?
session_start();
include ('dbconnect.php');
function get_writing_record($id)
{
$conn = db_connect();
$db = mysql_select_db('studiocommunity', $conn)
or die("Unable to access user information in database, try again later.");
$sql = "select * from user_writings where id = '" . $_REQUEST['id'] . "'";
$result = mysql_query($sql, $conn);
return(mysql_fetch_array($result));
}
if (isset($HTTP_GET_VARS['id']))
$w = get_writing_record($HTTP_GET_VARS['id']);
?>
<center>
<form action="writingsubmit.php" method="post">
<input type="hidden" name="writing" value="<? print $HTTP_GET_VARS['id']; ?>">
<table>
<tr><td align="center">Title</td></tr>
<tr><td><input size="40" name="title" value="<? print $w['title']; ?>"></td></tr>
<tr><td align="center">Writing Text - Can contain HTML text</td></tr>
<tr><td><textarea cols="40" rows="7" name="writing_text" wrap="virtual">
<? print $w['writing']; ?>
</textarea></td></tr>
<tr><td align="center"><input type="submit" value="Submit"></td></tr>
</table>
</form>
</center>
[/code]
I cannot figure out what is wrong, help please. -
That would not make any sense, because my login script works fine when it calls for dbconnect.php...
should i use the require() function instead of the include() function? -
Anybody?
-
I run these scripts and the second one gives me this error:
[b]There was a database error when executing
insert into user_writings
(title, writing_text, user, date)
values
('Test', '', '', 1142827344)
No database selected[/b]
here are the scripts in the order i access/run them.
writingforms.php
[code]
<?
include ('dbconnect.php');
function get_writing_record($story)
{
$conn = db_connect();
$sql = "select * from user_writings where id = '$writing'";
$result = mysql_query($sql, $conn);
return(mysql_fetch_array($result));
}
if (isset($HTTP_GET_VARS['writing']))
$w = get_writing_record($HTTP_GET_VARS['writing']);
?>
<form action="writingsubmit.php" method="post">
<input type="hidden" name="writing" value="<? print $HTTP_GET_VARS['writing']; ?>">
<table>
<tr><td align="center">Title</td></tr>
<tr><td><input size="40" name="title" value="<? print $s['title']; ?>"></td></tr>
<tr><td align="center">Writing Text - Can contain HTML text</td></tr>
<td><td><textarea cols="40" rows="7" name="writing_text" wrap="virtual">
<? print $w['writing']; ?>
</textarea></td></tr>
<tr><td align="center"><input type="submit" value="Submit"></td></tr>
</table>
</form>
[/code]
and writingsubmit.php
[code]
<?
include('dbconnect.php');
$conn = db_connect();
$title = $HTTP_POST_VARS['title'];
$time = time();
$writing_text = $HTTP_POST_VARS['writing_text'];
if (isset($HTTP_POST_VARS['writing']) && $HTTP_POST_VARS['writing'] !='')
{ //its an update
$writing = $HTTP_POST_VARS['writing'];
$sql = "update user_writings
set title = '$title',
writing_text = '$writing_text',
date = $time
where id = $writing";
}
else { //its a new story
$sql = "insert into user_writings
(title, writing_text, user, date)
values
('$title', '$writing', '" .$HTTP_SESSION_VARS['valid_user']."', $time)";
}
$result2 = mysql_query($sql, $conn);
if (!$result2) {
print "There was a database error when executing <pre>$sql</pre>";
print mysql_error();
exit;
}
?>
[/code]
what is wrong. -
Is it possible to place an IF statement in an IF statement?
-
Ah, wow thanks a lot.
-
How do i assign ID's to my database input, for instance if somebody fills in a field with something, and that is recorded to the DB how do I assign an ID to the entry (ie 1, 2, 3 4, ...)?
-
Oh, wow, thanks a lot that worked.
Next-Previous links not working.
in PHP Coding Help
Posted