Jump to content

lbaxterl

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lbaxterl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry i posted code i was messing around with there here is the working code (in firefox at least), it still outputs the last record having a comma after it. <?php include "config.inc.php"; $num = 1; function checkNum($num){ return ($num%2) ? TRUE : FALSE; } $result = mysql_query( "SELECT photo_id, photo_filename FROM gallery_photos WHERE photo_category= 6 AND promo= 1 "); $nr = mysql_num_rows( $result ); $NumOfRecords = mysql_num_rows($result); while($row = mysql_fetch_array($result)) { $id = $row['photo_id']; $img = $row['photo_filename']; if(checkNum($num) === TRUE){ echo " { src: 'admin/photos/".$img."', dir: 'left' },"; $num++; } else{ echo " { src: 'admin/photos/".$img."', dir: 'right' },"; $num++; } } ?>
  2. I have the following script which outputs different results based on weather a result is odd or even, pretty simple. The prblem lies with the very last result ouputted, as you can see from the code it will have a comma trailing it, which causes IE to not display the gallery. Can Anyone advise me on how to remove this last comma/echo the last result differently. Thank you <?php include "config.inc.php"; $num = 1; function checkNum($num){ return ($num%2) ? TRUE : FALSE; } $result = mysql_query( "SELECT photo_id, photo_filename FROM gallery_photos WHERE photo_category= 6 AND promo= 1 "); $nr = mysql_num_rows( $result ); $NumOfRecords = mysql_num_rows($result); while($row = mysql_fetch_array($result)) { $id = $row['photo_id']; $img = $row['photo_filename']; if(checkNum($num) === TRUE){ echo " { src: 'admin/photos/".$img."', dir: 'left' },"; $num++; } elseif ($num == $NumOfRecords) { echo " { src: 'admin/photos/".$img."', dir: 'left' }"; } else{ echo " { src: 'admin/photos/".$img."', dir: 'right' },"; $num++; } } ?>
  3. Ignore the last message, It isn't working as expected. I have the boxes checking based off the values in the database problem is if i check say the 10th row of the table and submit them it doesn't update that row of the database it updates the next blank one? I hope that makes sense. Thanks again
  4. Thanks, that was a big help, although that way didn't update the values in the db, I was able to modify it though, heres the code if your interested: <td align="center"><input name="published[]" type="checkbox" id="published" value="1" <? echo $rows['published'] == 1 ? ' checked="checked"' : ''; ?>></td> Thanks a lot! I appreciate it!
  5. I am having trouble setting a checkbox to "checked" if the row "published" is set to "1" (0 being not checked). I know this involves an if published==1 then print "checked", but i just cant get it to work. Any help would be greatly apprecatied: <?php include "base.php"; $sql="SELECT * FROM project"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>title</strong></td> <td align="center"><strong>Published</strong></td> <td align="center"><strong>Promoted</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ $pub = $rows['publised']; ?> <tr> <td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td align="center"><? echo $rows['title']; ?></td> <td align="center"><input name="published[]" type="checkbox" id="published" value="<? echo $rows['published']; ?>"></td> <td align="center"><input name="promoted[]" type="text" id="promoted" value="<? echo $rows['promoted']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE project SET published='$published[$i]', promoted='$promoted[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:update_multiple.php"); } mysql_close(); ?>
  6. thank you so much need to save as ansi files, is there a easy way to convert them all in dreamweaver?
  7. sorry there was no white space i double taped enter before posting the code stupidly sorry, any other ideas could it be a server issue?
  8. Im creating a login form but everytime i try to output a header or start a session i get errors: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /web/users/e5034824/Test/confirmlogin.php:1) in /web/users/e5034824/Test/confirmlogin.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /web/users/e5034824/Test/confirmlogin.php:1) in /web/users/e5034824/Test/confirmlogin.php on line 2 <?php session_start(); $username = $_POST['myusername']; $password = $_POST['mypassword']; require 'common.php'; $q = "SELECT id FROM members WHERE username = '$username' AND password = '$password'"; $result = $mysqli->query($q) or die(mysqli_error()); if (mysqli_num_rows($result) == 1) { $user = $result->fetch_array(MYSQLI_NUM); $_SESSION['admin'] = $user[0]; // Sets the session to the user's ID } else { $message = "User Name Not Recongised, Please Try Again!"; echo $message . ' <meta HTTP-EQUIV="refresh" content=5;url="login.php"/>'; } ?> I always get the header error message but have no clue on how to fix it any ideas?
  9. thanks ive implemented the code but now im being bombarded with errors: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /web/users/e5034824/Test/confirmlogin.php:1) in /web/users/e5034824/Test/confirmlogin.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /web/users/e5034824/Test/confirmlogin.php:1) in /web/users/e5034824/Test/confirmlogin.php on line 2 <?php session_start(); $username = $_POST['myusername']; $password = $_POST['mypassword']; require 'common.php'; $q = "SELECT id FROM members WHERE username = '$username' AND password = '$password'"; $result = $mysqli->query($q) or die(mysqli_error()); if (mysqli_num_rows($result) == 1) { $user = $result->fetch_array(MYSQLI_NUM); $_SESSION['admin'] = $user[0]; // Sets the session to the user's ID } else { $message = "User Name Not Recongised, Please Try Again!"; echo $message . ' <meta HTTP-EQUIV="refresh" content=5;url="login.php"/>'; } ?> I always get the header error message but have no clue on how to fix it any ideas?
  10. Hi im implementing a login form in my site and i wanted to know how i would adopt it to use sessions, allowing access to the admin page only if the user is logged in. Ive posted the login form and the confirm login script below any help appreciated. Login form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <style type="text/css"> body { text-align: center; font-family: helvetica; } #loginForm { padding: 1em; background: #e3e3e3; width: 260px; margin: 3em auto 0; text-align: left; } </style> <body> <div id="loginForm"> <form name="form1" method="post" action="confirmlogin.php"> <h2>LOGIN</h2> <p>Username: <input type="text" name="myusername" id="myusername" /></p> <p>Password: <input type="text" name="mypassword" id="mypassword"/></p> <p><input type="submit" value="Login" name="submit" /></p> </form> </div> </body> </html> confirmlogin.php <?php $username = $_POST['myusername']; $password = $_POST['mypassword']; require 'common.php'; $q = "SELECT id FROM members WHERE username = '$username' AND password = '$password'"; $result = $mysqli->query($q) or die(mysqli_error()); if (mysqli_num_rows($result) == 1) { echo ' <meta HTTP-EQUIV="refresh" content=0;url="admin.php"/>'; } else { $message = "User Name Not Recongised, Please Try Again!"; echo $message . ' <meta HTTP-EQUIV="refresh" content=5;url="login.php"/>'; } ?> thank you
  11. ok the servers back up! now its outputting these errors but echoing the $source and $target: Warning: move_uploaded_file(img/photo/n656985202_6030227_7816996.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /web/users/e5034824/Test/admin.php on line 31 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpij8aCM' to 'img/photo/n656985202_6030227_7816996.jpg' in /web/users/e5034824/Test/admin.php on line 31
  12. i think were getting somewhere when insert the code you gave: print_r($_FILES['fupload']); i get this message: Array ( [name] => Capture.jpg [type] => [tmp_name] => [error] => 2 => 0 )
  13. the target returns img/photo/capture.jpg. the source returns nothing
  14. removed the add slashes, it didnt work, the info is still entered into the database though! thanks for the help guys
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.