-
Posts
902 -
Joined
-
Last visited
-
Days Won
9
Posts posted by doddsey_65
-
-
sorry but i dont understand any of that?
-
When a user uploads their image i want to be able to get the dimensions and resize accordingly before the image is uploaded. I want the images to be only 100x100. how would i go about this? I already have an upload function just need these things added to it.
-
Sorry for the triple post but i cant or rather dont want to move onto another part of my site without this working.
-
Okay i got the format to work but when i click next page it just shows up the same results not the next ones.
<?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 3; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; echo '<div id="page">'; echo '<div id="content"><br />'; echo '<h2 class="title">Tutorials By Hamish Hill</h2><br />'; $sql = "SELECT name, fullname, description, link, path FROM tutorials WHERE username='hamsterhill' $max"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo '<div class="post">'; echo '<p class="meta">' .$row["fullname"]. ' | ' .$row["name"]. '<img src="images/img08.png" alt="bullet"></p>'; echo '<div class="entry">'; echo '<p><img src=' .$row['path']. ' hspace=10 align=left>'; echo $row['description']. '</p>'; echo '</div>'; echo '</div>'; } echo "<p> Page $pagenum of $last </p>"; if ($pagenum == 1) { } else { echo " <p><a href='{$_SERVER['PHP_SELF']}?pagenum=1' class=links> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous' class=links> <-Previous</a> </p>"; } if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <p><a href='{$_SERVER['PHP_SELF']}?pagenum=$next' class=links>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last' class=links>Last ->></a></p> "; } echo '</div>'; include('footer.php'); ob_flush(); ?>
-
do you mean you want to use the same hex color to specify background or something? if so something like PSP or GIMP tells you what the hex color is
-
Okay here is the page in question: http://blenderteachings.000a.biz/tutorials.hamishhill.php
I have the records in a database(tutorial name, username description etc). I am pulling these and displaying them but i need them to be set out like this http://blenderteachings.000a.biz/index.php
But my code doesnt do it like that. Any ideas?
Heres the code:
<?php ob_start(); include('header.php'); include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); if (!(isset($pagenum))) { $pagenum = 1; } $data = mysql_query("SELECT * FROM tutorials") or die(mysql_error()); $rows = mysql_num_rows($data); $page_rows = 3; $last = ceil($rows/$page_rows); if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $sql = "SELECT username, fullname, description, link FROM tutorials WHERE username='hamsterhill' $max"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { ?> <div id="page"> <div id="content"><br> <div class="post"> <p class="meta"><?php echo $row["fullname"] . ' | ' .$row["username"]; ?> <img src="images/img08.png" alt="bullet"></p> <div class="entry"> <?php echo $row['description']; echo '<br />'; } ?> </div> </div> <?php echo " Page $pagenum of $last <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> </div> <?php include('footer.php'); ob_flush(); mysql_close($db); ?>
-
Try:
$sql =("UPDATE users SET points='$points' WHERE username='$user_edit'") or die(mysql_error()); $result = mysql_query($sql, $connect);
-
that didn fix it, however i am using row in header.php which is included in every file but i thought it would be ok if i closed the connetion at the end of header.php? Is there a was around this? And yes the field type is INT
-
I want to select values from a db table and return them but when i echo the name field it brings a result from a dif table.
include('db.php'); $db=mysql_connect($db_host,$db_user,$db_pass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($db_name,$db); $query= "SELECT name, description, link, username, fullname FROM 'tutorials' WHERE id=1"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($res) ? <p class="meta"><?php echo $row['username']; ?>
-
ok well i think the easiest thing to do is get rid lol, its not really an important feature as the site isnt a foru or anything like that just a tut site. Cheers anyway, but i think working round this is gonna cause more problems than i need lol.
-
so if there is no way to delete the record when they are logged out automatically how would i change this code so they arent logged out automatically, and would that even be feasable(spelling?) ie security?
-
I have a login system setup and i made it echo number of users online by inserting the username into a dif tble when they log in and echoing the numrows in tht table. And when they logout it is removed, however when the session times out and they are logged out automatically it doesnt delete the row so it still says there is a user online. Here is the logout code:
<?php $username = $_COOKIE['ID_my_site']; $db=mysql_connect("myinfo") or die(mysql_error()); mysql_select_db("mydb") or die(mysql_error()); $past = time() - 100; setcookie(ID_my_site, gone, $past); setcookie(Key_my_site, gone, $past); $sql="DELETE FROM online WHERE username = '$username'"; header("Location: index.php"); ?>
-
@mattyvx:
yeh that did it, although i did it before reading this i cant believe i missed the fact that i wasnt even running the query lol, bit embarrising but atleast it works now. Cheers for he help guys
-
yep and there are no errors at all
-
Okay here is the code:
if (isset ($_COOKIE['ID_my_site'])) { $username = mysql_real_escape_string($_COOKIE['ID_my_site']); $pass = mysql_real_escape_string($_COOKIE['Key_my_site']); $check = mysql_query("SELECT * FROM users WHERE username = '{$username}'")or trigger_error (mysql_error()); if (mysql_num_rows ($check) > 0) { $info = mysql_fetch_array ($check); //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } else { $uploadDir = 'uploads/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $query = ("UPDATE users SET path='$filePath' WHERE username='$username'"); echo $query; } } } } else { header("Location: login.php"); exit (0); } ob_flush(); ?>
When i run it the image is uploaded to the server but the db row isnt updated. Yet when i echo the query and put that into phpmyadmin it works fine. So why doesnt it work in php?
Cheers
-
Okay i did an echo on the query and came up with this:
UPDATE users SET path = "uploads/sbbody-l.gif" WHERE username = "doddsey_65"
And when run in phpmyadmin it works fine and updates the row, so why doesnt it do this when i run it within the php file?
-
<?php $to_email = "info@ideatoceo.com"; $subject = "Greetings"; $message = echo '<table width="676"><tr>Hi <td width="30" height="52"><img src="Side.gif" width="30" height="50" alt="Corner" /></td> <td width="600"><img src="Top.gif" width="600" height="50" alt="Top" /></td> <td width="30"><img src="Side.gif" width="30" height="50" alt="Corner" /> </td></tr></table>'; ?>
-
Okay my code doesnt seem to work but i dont know why
$uploadDir = 'uploads/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $filePath = addslashes($filePath); } $query = ("UPDATE users SET path = '$filepath' WHERE username = '$username'") or die (mysql_error());
It uploads the image but not the path
Username is already defined earlier in the code and my form is fine. Can anyone see why its not working?
-
@emopoops that makes no sense that he would delete a user by the url. you should never delete a user by a name or age or some other value that can be in another users field. There should be a unique value in the database that identifies the user. Hence the use of an incrementing id. Then you can delete it by using its UNIQUE id. Almost every table I make in the database has a unique id.
same here, i have an ai on an id table. cheers for the help people. I did think halfway through however why dont i just gointo the database and delete them, but im going to use this way anyway cos my db loads too slowly. Cheers
-
DELETE FROM table WHERE url = '$badurl'
sorry mate but that made no sense lol
-
I presume you have a unique ID column for the table users right?
yes, but how would i get the hyperlink to know its the user next to it that i want it to delete
Eg. User: Tom [delete]
User: Dick [delete]
User: Harry[delete]
How would i delete tom with the code i am using to display them
-
You can have the button or the link next to it contain a unique ID corresponding to the row entry in the DB you want to remove.
how would i go about doing that?
-
I currently have a user managment system im working on. What i want is to have a hyperlink next to the rows that are pulled(see code below). with this button i can delete the respective row from the db therefore deleting the user. Here is the code i am using to display their details:
$sql = "SELECT name, email, date FROM users"; $res = mysql_query($sql, $db); while($row = mysql_fetch_array($res, MYSQL_ASSOC)) { echo $row['name'] . ": " . $row['email'] . " -- " . $row['date']; echo "<br />"; }
I know how to delete records, what i dont know how to do is to delete the record I want ie. the one next to the delete link if you know what i mean.
-
okay all i want to do atm is see if the email gets hthrough, so additional stuff can be held back for the min, what do i need my host to do so the email does go through?
Get image dimensions
in PHP Coding Help
Posted
i have an image resizing script:
Is there any way i can incoroprate this into the upload form?