Jump to content
Larry Ullman's Book Forums

Dark Prince

Members
  • Posts

    62
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Dark Prince

  1. if you have it setup where the person has to be logged in then create a table in mysql that logs there userid and the poll id then if it exists give the error that they already answered the poll if not you can log there ip address instead of a userid, when using cookies they can easily delete it and poll again atleat with a database they can't

    • Upvote 3
  2. Hey guys I'm having a problem with my syntax IT ISN'T working -_-

     

    this is the working code

     

    $bg = '#fff000'; // initial bg color.

    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {

    $bg = ($bg=='#fff000' ? '#000fff' : '#fff000');

     

    now instead of using color codes I want to use png files from my includes folder I've tried using a relative path and a fixed path didn't work obviously can't just link an image and expect it to work.

     

    then I tried using $bg = ' echo "<img src=\"http://localhost/includes/file.png\"/>"; '

    didn't work either just showed a solid red color for every row. should of been blue to yellow to blue.

     

    then I tried using a direct path instead of localhost I used D:/XAMPP/htdocs/includes/file.png

    didn't work either...

     

    what would be the proper syntax to use png files for a background image that alternates every returned row like the above code using color codes?

  3. not exactly what im looking for, i need to use the getcwd function then strip everything but the folder name and make it a value, the reason is when someone signs up a folder is created with there username and an index file is copied to it, now that index file needs to know what user info to pull from the database by using the foldername this way that page can be loaded without having to follow links or sending information through the server or browser and can be accessed through the address bars.

  4. Ok seems like the world wide web is starting to go the way of folders so I want to keep with the trend, in my script folders are created using the mkdir function then an index file pertaining to that type of folder is copied from another existing folder.

     

    Now what I need to do is get the new folders name to be used as a value in php for that index file that was just copied to it, to know where from the database to get its information instead of having

     

    www.website.com/page.php?someid=whatever

     

    I want to have

     

    www.website.com/folder

  5. even without the bleeding the footer still shows above the last 2 div blocks, and in my stylesheet the footer's styling is the last thing run, still don't understand why its doing it it should be a table of comments, then a textarea to add a comment and then the end of the body content then the footer. instead it goes footer, comments, commentbox.

     

    as for the bleeding again is there a way to do a preg match and check for no spaces in $_POST? or even simpler just check to see if no spaces exist in the field at all?

  6. ok I'm trying to find away to eliminate the bleeding effect of no spaces when entered into a database and being returned into a table.

     

    eg. say someone for the hell of it uses no spaces for a very long string, when returned in a table it bleeds the page for that cell.

     

    I've tried using width controls with percent values in the html td tags still bleeds.

     

    I want my pages to fit exactly inside the browser window with no horizontal scroll bars I use 1% margin on my main body content in css like margin:1% 1% 1% 1%;

     

    and in the tag its like this <td align="center" width="25"%> </td>

     

    so if someone enters a run-on word into an input field it doesn't break it for the td's width it stretches it right to the end of the run-on word.

     

    ???????

  7. Yeah if I run http://localhost/ in my browser it will load any page named index in there I could of set the directory wrong for the $dir token but using http://localhost/upload worked I didn't try it your way yet using ('./uploads') but I think it's because the script I'm working on is in a folder inside the htdocs folder and some reason I can only go back 1 folder in php ../../ doesn't work for going back more folders

  8. somehow its not getting all the information it needs out of the file which is intact in its original state I didn't change anything of it this time in the code I just took its information and put into the uploads table in the database just for reference. so if I take the name the type and the size and put that into the database table for uploads can I take that information and make a temporary file inside the htdocs then use that file as the img src? I know larry uses urlencode when sending the file to a new window but I need to display in same window inside an html table row where the image is going to change for everyrow.

  9. even using the file inside the htdocs it still doesn't show the image I put the alt="' . $row['column'] . '" in the img tag and it will show the information from the row but not the picture

     

    the picture is stored in XAMPP/htdocs/upload/userid

     

    and still doing the same thing when I right click on the icon on the browser and hit properties it shows

    2.jpg

    Protocol: Not Available

    Type: Not Available

    Address(URL): Not Available

    Size: Not Available

    Dimensions: 75 x 75 pixels

  10. so pretty much need to take the file from the uploads directory and create it as a temp in the htdocs folder? I have everything to do with php mysql and apache on a partition called D:/ so my phptemp and phpul is just outside the xampp folder

    D:\

    |-phptmp

    |-phpul/userid/file.ext

    |-xampp/htdocs/sitefolder/script.php

     

    thats the directory setup best way I can show it.

  11. Ok so I've had some success inside the row it is still only showing an image icon. when I click on the properties of the image it shows the name with extension but the rest of the info is empty, this is the new code

     

    the $dir value is set like this $dir = 'D:/phpul';

    the image1 row in the database is the files name with extension now and the folder it is stored in is the same as the userid so with the code below the browser should show it as <img src="D:/phpul/1/2.jpg" width="75" height="75"/>

    but it does not? I've checked the folder itself the file is there in the userid folder in the phpul directory.

     

    <td align="center"><img src="'.$dir.'/'.$row['userid'].'/'.$row['image1'].'" width="75" height="75"/></td>

     

    I know i'm dragging this topic on quite a bit but I'm doing this for a friend out my own good will.

  12. ugh ok so I looked through the scripts from 2nd edition glad I still had those, the way larry does it is he sends them into another window to be downloaded via the header function :(

     

    // Check for an upload_id.

    if (isset($_GET['uid'])) {

    $uid = (int) $_GET['uid'];

    } else { // Big problem!

    $uid = 0;

    }

    if ($uid > 0) { // Do not proceed!

    require_once ('../mysql_connect.php'); // Connect to the database.

    // Get the information for this file.

    $query = "SELECT file_name, file_type, file_size FROM uploads WHERE upload_id=$uid";

    $result = mysql_query ($query);

    list ($fn, $ft, $fs) = mysql_fetch_array ($result, MYSQL_NUM);

    mysql_close(); // Close the database connection.

    // Determine the file name on the server.

    $the_file = '../uploads/' . $uid;

     

    // Check if it exists.

    if (file_exists ($the_file)) {

     

    // Send the file.

    header ("Content-Type: $ft\n");

    header ("Content-disposition: attachment; filename=\"$fn\"\n");

    header ("Content-Length: $fs\n");

    readfile ($the_file);

  13. yes because $row is the first query for the loop the $rowi is for the images information in the uploads directory. and I think larry used a loop to do the file uploads the way I did I just took the loop out and did each one by itself.

     

    Making sub directories was going to my next step if this wouldn't work some reason I make things more complicated then they should be lol sorry guys I'll see what I can do to re-write this.

  14. ok still not working in my database the columns show up like this

     

    Field-----------Type-----------Null------Key------Default------Extra--

    userid---int(10)unsigned-----NO------PRI-------NULL----auto_increment

    email-------varchar(90)-------NO------UNI-------NULL-----------------

    password---char(40)---------YES-----------------NULL----------------

    username---char(40)---------NO------UNI--------NULL---------------

    active--------char(32)---------NO------------------NULL----------------

    regdate-----datetime---------NO-------------------NULL----------------

  15. This is the script with row names removed to protect my friends information for the site

     

    $dir = "D:/phpul/";

    // Query.

    $query = "SELECT row1, row2, row3, row4, image1, DATE_FORMAT(datetime, '%M %d, %Y') as dr, rowid FROM table ORDER BY $order_by LIMIT $start, $display";

    $result = mysqli_query ($dbc, $query);

    ?>

    <br/>

    <div align="center"><h2><p>Table Title</p></h2></div>

    <?php

    // Table header.

    echo '

    <fieldset id="fieldset1">

    <table align="center" cellspacing="10" cellpadding="10" width="90%">

    <tr>

    <td align="center"><b><a href="index.php?sort=ast">row1 name</a></b></td>

    <td align="center"><b>Photo</b></td>

    <td align="center"><b>row2 name</b></td>

    <td align="center"><b><a href="index.php?sort=asp">row3 name</a></b></td>

    <td align="center"><b><a href="index.php?sort=asl">row4 name</a></b></td>

    <td align="center"><b><a href="index.php?sort=asr">date added to database</a></b></td>

    </tr>

    ';

    // Fetch and print table rows.

    $bg = '#eeeeee'; // initial bg color.

    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {

    $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');

    echo '<tr bgcolor="' . $bg . '">

    <td align="center"><a href="somepage.php?id=' . $row['rowid'] . '">' . $row['row1'] . '</a></td>

    <td align="center">';

    $queryi = "SELECT image_name FROM uploads WHERE (imageid='$row[image1]')";

    $resulti = mysqli_query ($dbc, $queryi);

    $rowi = mysqli_fetch_array($resulti, MYSQLI_ASSOC);

    $imageid = $row['image1'];

    $imagename = $rowi['image_name'];

    echo '<img src="' . $dir . '' .$imagename . '"/></td> (now this obviously doesn't work because that file is stored without a name in the upload directory so shows as an unavailable picture aka the picture icon for IE)

    <td align="center">' . $row['row2'] . '</td>

    <td align="center">' . $row['row3'] . '</td>

    <td align="center">' . $row['row4'] . '</td>

    <td align="center">' . $row['dr'] . '</td>

    </tr>

    ';

    mysqli_free_result ($resulti);

    }

    echo '</table></fieldset>';

    mysqli_free_result ($result);

    mysqli_close($dbc);

     

     

    now the script that handles the file uploads is this. (this takes the filename with extension and type then stores it in the uploads table. Then it changes the filename to and ID number without an extension and moves it to the uploads directory but that name is the same as its ID in the uploads table.

     

    if (isset($_FILES['i1']) && ($_FILES['i1']['error'] != 4)) {

    $queryi1 = "INSERT INTO uploads (image_name, image_type) VALUES ('{$_FILES['i1']['name']}', '{$_FILES['i1']['type']}')";

    $resulti1 = mysqli_query ($dbc, $queryi1);

    if ($resulti1) {

    $idi1 = mysqli_insert_id($dbc);

    move_uploaded_file($_FILES['i1']['tmp_name'], "D:/phpul/$idi1");

    }

    } else {

    $idi1 = "NULL";

    }

    if (isset($_FILES['i2']) && ($_FILES['i2']['error'] != 4)) {

    $queryi2 = "INSERT INTO uploads (image_name, image_type) VALUES ('{$_FILES['i2']['name']}', '{$_FILES['i2']['type']}')";

    $resulti2 = mysqli_query ($dbc, $queryi2);

    if ($resulti2) {

    $idi2 = mysqli_insert_id ($dbc);

    move_uploaded_file($_FILES['i2']['tmp_name'], "D:/phpul/$idi2");

    }

    } else {

    $idi2 = "NULL";

    }

    if (isset($_FILES['i3']) && ($_FILES['i3']['error'] != 4)) {

    $queryi3 = "INSERT INTO uploads (image_name, image_type) VALUES ('{$_FILES['i3']['name']}', '{$_FILES['i3']['type']}')";

    $resulti3 = mysqli_query ($dbc, $queryi3);

    if ($resulti3) {

    $idi3 = mysqli_insert_id ($dbc);

    move_uploaded_file($_FILES['i3']['tmp_name'], "D:/phpul/$idi3");

    }

    } else {

    $idi3 = "NULL";

    }

    if (isset($_FILES['i4']) && ($_FILES['i4']['error'] != 4)) {

    $queryi4 = "INSERT INTO uploads (image_name, image_type) VALUES ('{$_FILES['i4']['name']}', '{$_FILES['i4']['type']}')";

    $resulti4 = mysqli_query ($dbc, $queryi4);

    if ($resulti4) {

    $idi4 = mysqli_insert_id ($dbc);

    move_uploaded_file($_FILES['i4']['tmp_name'], "D:/phpul/$idi4");

    }

    } else {

    $idi4 = "NULL";

    }

    if (isset($_FILES['i5']) && ($_FILES['i5']['error'] != 4)) {

    $queryi5 = "INSERT INTO uploads (image_name, image_type) VALUES ('{$_FILES['i5']['name']}', '{$_FILES['i5']['type']}')";

    $resulti5 = mysqli_query ($dbc, $queryi5);

    if ($resulti5) {

    $idi5 = mysqli_insert_id ($dbc);

    move_uploaded_file($_FILES['i5']['tmp_name'], "D:/phpul/$idi5");

    }

    } else {

    $idi5 = "NULL";

    }

    if (isset($_FILES['i6']) && ($_FILES['i6']['error'] != 4)) {

    $queryi6 = "INSERT INTO uploads (image_name, image_type) VALUES ('{$_FILES['i6']['name']}', '{$_FILES['i6']['type']}')";

    $resulti6 = mysqli_query ($dbc, $queryi6);

    if ($resulti6) {

    $idi6 = mysqli_insert_id ($dbc);

    move_uploaded_file($_FILES['i6']['tmp_name'], "D:/phpul/$idi6");

    }

    } else {

    $idi6 = "NULL";

    }

     

    now $idi1 through $idi6 which are now mysql id's and primary keys are stored in the main table in the database so they can be distinquished to that INSERT only and there information from the uploads table can be linked to them for the main tables primary key

     

    but the columns name are not foreign to each other because the main table can take 6 image id's for 1 row so the rest of the query in the submit page looks like this

     

    $query = "INSERT INTO sometable (somecolumn, somecolumn, somecolumn, somecolumn, somecolumn, somecolumn, somecolumn, somecolumn, somecolumn, some column, image1, image2, image3, image4, image5, image6, datetime) VALUES ('$definedvalue', '$definedvalue', '$definedvalue', '$definedvalue', '$definedvalue', '$definedvalue', '$definedvalue', '$definedvalue', '$definevalue', '$definedvalue', '$idi1', '$idi2', '$idi3', '$idi4', '$idi5', '$idi6', NOW() )";

    $result = mysqli_query ($dbc, $query);

     

    now somecolumn isn't whats actually in the code they are the column names in the main table and same with $definedvalue they are values taken from form fields.

     

    hope this can help clear up more as to what I'm working with and trying to do.

×
×
  • Create New...