Jump to content

elrobbo6

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

elrobbo6's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK, so the long of what i am trying to do is take images from folder(A) on one server and using web services transfer all of those images to database table(B) on another server. I want it to do this automatically whenever there is a new image put into folder (A). So far I have it transferring the file name but not the actually image itself. This is the code i am using for that.... <?php $dir = opendir("images"); //List files in images directory while (($file = readdir($dir)) !== false) { if ($file != "." && $file != "..") { addData(); } } function addData() //populate Orders sample table with data //insert new record into Orders sample table { global $tableName, $wsdl, $file; $file = substr($file, 0, -4); //Caspio Bridge WS API WSDL file $wsdl = "https://b4.caspio.com/ws/api.asmx?wsdl"; //Caspio Bridge table with sample data $tableName = "Images"; //Caspio Bridge account name $name = "XXXXX"; //Web service profile $profile = "XXXXXXX"; //Web service profile password $password = "XXXXXXXXXXXXXX"; try { //init the SOAP Client $client = new SoapClient($wsdl); //WS API call $client->InsertData($name, $profile, $password, $tableName, false, "Date_added, Image_name","getdate(), '$file'"); } catch (SoapFault $fault) { //SOAP fault handling $str = "<h1><b>Fault:</b> faultcode: {$fault->faultcode}, <b>faultstring:</b> {$fault->faultstring}</h1>"; print($str); } } ?> as you can see i am just looping through to get all the names. This same system is not working for the images though. It only displays one. And wont transfer to Table (B). I am at a loss. So if anyone has any code snippits or advice or anything on parts of this or even the whole thing please please let me know! Thank you! MOD EDIT: code tags added.
  2. they are in a folder on the server. I just want to move them from the folder they are in into a database
  3. I have been looking around and have not been able to find any useful information on this. I am trying to transfer files from a folder in the directory to a table in a database. Eventually they will be images but for right now I am just trying to get text files to transfer. Any help/code/ideas would be a lot of help. This is going to be triggered a button on a page by the way.
  4. OK, so I have a question about databases and how they sort things being loaded into them. I have a database that I have images uploaded to (some people dont like to do it this way but this is what is going to work for my project). I have it set up with an id column that auto-increments. When I upload the files for some reason it is putting the highest id number first and the second one is the lowest then it goes in order from there. Why would this be happening and how do I correct it?
  5. So I am trying to pull the first image that was uploaded to the database. But for some reason this only works part of the time and if you delete any image in the database it seems to just pic another another random one. Any suggestions? <?php { $row = getad(); header("Content-type: image/jpeg"); $pic = ($row['image']); print "$pic"; } function getad() { $ads = array(); mysql_connect("localhost","******","********"); mysql_select_db("users"); $query = "SELECT image FROM image_ads"; $result = mysql_query($query); $i = 0; while($row = mysql_fetch_array($result)) { $i ++; $ads[$i] = $row; } $id = date("z"); $index = $id % $i + 1; mysql_close(); return $ads[$index]; } ?>
  6. SWEET! Ok, I figured it out so I thought I would post it for anyone else having this problem... $useranswer= ( $_POST['Text1']); $query = "SELECT Answer FROM images_guess WHERE id=16"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $realanswer = $row['Answer']; <-----------------------just turned the actual text pulled in into a variable echo "Answer :$realanswer <br>"; echo "User Answer:$useranswer <br>"; } if ($realanswer==$useranswer) echo "right"; else echo "wrong"; ?> Thanks a bunch you guys!!!
  7. ah, I thought it might be something like that. Basically the $useranswer= ( $_POST["Text1"]); is what a user types into a text field on a html page. and the $result = mysql_query($query); is a row called 'Answer' containing text stored in a table from a database. So your saying I need to make the $result into something else? because when I use echo "Answer :{$row["Answer"]} <br>"; It does print that information. So how would I make a variable that is that text it pulls off the table? And I will check that website. thank you.
  8. the spaces were there because it was just the last thing i was trying. Any way you could show a sample code using what you were talking about?
  9. Hello everyone, I am having major issues trying to figure this one out. So here is the code.... $useranswer= ( $_POST["Text1"]); $query = "SELECT Answer FROM images_guess WHERE id=16"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Answer :{$row["Answer"]} <br>"; echo "User Answer:$useranswer <br>"; } $result2 = $result. " "; $useranswer2 = $useranswer . " "; if ($result2==$useranswer2) echo "right"; else echo "wrong"; ?> Basically, I am taking whatever was put into "Text1" and finding out if it matches what was in the Answer row in my table. The two variables I used, $result and $useranswer are both working because they do print out on the next page. The problem is the If/else statement is not working with them. They are both text if that helps. Any advice would help a ton, i'm at a loss. Thanks!
×
×
  • 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.