Jump to content

lamajlooc

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lamajlooc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is probably a dumb question, but I'm getting stumped. I'm using AdBrite's video API that allows you to add a video to their service dynamically and sends back XML data including the code you include on your blog or wherever. Specifically, here is the problem I'm solving: 1) Presently a user adds a video to our system using our web form, inputting all the needed data (title, description, tags, etc.) and uploads the file. 2) We then manually add the data for that video to AdBrite's system so we can serve ads on the videos on our site. This is obviously cumbersome and will only grow more so as more users join the site (hopefully). AdBrite is nice enough to have provided an API so that the process can be automated. My problem is that I don't know how to "ping" their API and receive and store the code they send back via and XML file. I've URI-encoded all the parameters they ask for and I've tested the URI using header();. It works and I get the XML code, but it's just posted to the browser window, not my program, obviously. My question is how I send the URI-encoded data to their API from within my program without leaving the program and how I retrieve the data they send back. They're less than helpful on their site. Here's what they say: Want a faster way to register your videos with Black Label Ads? Does your video site automate video uploading? If so, then you might be interested in using our API. Simply ping our API at https://www.adbrite.com/video/add_video_api.php with the required parameters, and if everything's OK, we'll send back an XML file with the appropriate code to put on your site. Example URI https://www.adbrite.com/video/add_video_api.php?username=YOUR_USERNAME&password=YOUR_PASSWORD&category_id=VALID_ID&v_rating=VALID_RATING&v_flv_url=VALID_URL&v_title=TITLE_STRING&v_description=DESCRIPTION_STRING&v_override_clickback={1,0}&v_page_url=VALID_URL&v_override_playback={1,0}&v_autostart={1,0}&v_preroll_image_url=VALID_URL&v_show_play_button_not={1,0}&v_show_preroll_image={1,0}&v_embed_override_global={1,0}&v_show_preroll_image_embed={1,0}&v_preroll_image_url_embed=VALID_URL&v_show_play_button_embed_not={1,0}&v_width=POSITIVE_INTEGER&v_height=POSITIVE_INTEGER&v_show_ads={1,0}&keywords=KEYWORDS_STRING https://www.adbrite.com/video/add_video_api.php?username=YOUR_USERNAME&password=YOUR_PASSWORD&category_id=412&v_rating=pg&v_flv_url=http%3A//www.mywebserver.com/video%3Fid%3Ds177Ys41t&v_title=My%20Summer%20Vacation&v_description=This%20is%20what%20I%20did%20last%20summer.%20What%20a%20trip%21&v_override_clickback=1&v_page_url=http%3A//www.mywebserver.com/pages%3Fpid%3D%20wps177Ys41t&v_override_playback=1&v_autostart=0&v_preroll_image_url=http%3A//www.mywebserver.com/images%3Fid%3Dwis177Ys41t&v_show_play_button_not=0&v_show_preroll_image=1&v_embed_override_global=1&v_show_preroll_image_embed=1&v_preroll_image_url_embed=http%3A//www.mywebserver.com/images%3Fid%3Dwis177Ys41t&v_show_play_button_embed_not=0&v_width=468&v_height=400&v_show_ads=1&keywords=summer%0Avacation%0Asummer%20vacation%0Atravel%0A Expected Return Values The general format of the return is an xml document with the following structure: <addvideo> <type><!-- error | success --></type> <message><!-- any message --></message> <!-- more message nodes --> </addvideo> The specific return values (as of now) are: <addvideo> <type>error</type> <message>User must save their global settings before using the api.</message> </addvideo> <addvideo> <type>error</type> <message>Invalid username or password</message> </addvideo> <addvideo> <type>success</type> <message><![CDATA[<!-- html code for your page. -->]]></message> <message><!-- video_id --></message> </addvideo> The URI being passed to them is fine, and they return the third set of XML data...what do I do now? Thanks in advance.
  2. <?php     include('./mysql_connect.php');     $query = "SELECT email FROM pmnl_email";     $result = mysql_query($query) or die(mysql_errno());     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {         echo "$row";         $query = "UPDATE users SET email = '$row[0]' WHERE email <> '$row[0]'";         $result = mysql_query($query) or die(mysql_errno());     }     mysql_close(); ?> What I want this code to do is to read all the emails from a database table (mysql_connect.php) and then update another table in the same database with those emails.  Am I retarded?  I've tried it with "if ($row = mysql_fetch_array($result, MYSQL_NUM)) {" and I get the same result.  I don't get any errors at all. But the other table is always empty. Also, if anyone can help me with THIS wierd thing:  When I try and browse the database "users" in phpMyAdmin it keeps sending me a file to download (which is blank) instead of letting me browse.  I've never had a database table that was empty so I don't know is this is regular behavior or not. Thanks guys.  You always help me out!
  3. Good idea.  I did that and it said the error was with the "ORDER BY name" so I took it out and now I get: Error in SELECT username, name, website, phone, email FROM users WHERE age = 20 AND race = '' AND zip = : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 So I took out the ' quotes around '$_POST[---]' in the query and I got an error with +++ attribute in the third if clause.  Could it be a problem with my if statements?  Can you write if(isset(blah) && !isset(blah)) { ?? Thanks for your help.
  4. Hi, I have a site where users register and display their wares with various attributes.  At the moment, I want results to be narrowed according to three attributes.  I have a script that reads through the DB and displays drop-down boxes with options taken only from the DB so there's no need for searching something that's not there.  For example it makes all the location options only from actual locations stored in the DB. I want it to be possible to narrow based on one, two or all three atrributes.  The problem I'm having now is that if I narrow for one or two I get an error.  Three works fine. Attribute 1 (***) is a number Attribute 2 (---) is a string Attribute 3 (+++) is a number Here's the error if one or two are searched for: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY name' at line 1 And here's the code: <?php     if (isset($_POST['submit'])) {         if (isset($_POST['***']) && !isset($_POST['---']) && !isset($_POST['+++'])) { // If *** searched for             include ('../mysql_connect.php');             $query = "SELECT username, name, website, phone, email FROM users WHERE *** = $_POST[***] ORDER BY name";             $result = mysql_query($query) or die(mysql_error());             while ($row = mysql_fetch_array($result, MYSQL_NUM)) {                 $un = $row[0];                 $n = $row[1];                 $w = $row[2];                 $p = $row[3];                 $e = $row[4];                 $query = "SELECT file_name FROM uploads WHERE username = '$un'";                 $result = mysql_query($query) or die(mysql_error());                 $found = FALSE;                 while ($rr = mysql_fetch_array($result, MYSQL_NUM)) {                     $file = $rr[0];                     echo "<table border=\"0\"><tr><td class=\"competing_im***s\">";                     echo "<a href=\"" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "users/$un/\"><img border=\"0\" src=\"./uploads/thumbs/th_$file\" /></a>";                     echo "</td><td class=\"competing_im***s\" style=\"text-align:left;\">";                     echo "$n<br />$w<br />$p<br />$e";                     echo "</td></tr></table>";                     $found = TRUE;                 }                 if ($found <> TRUE) {                     echo "Sorry, could not find any search terms.";                 }             }             mysql_close();         } elseif (isset($_POST['***']) && isset($_POST['---']) && !isset($_POST['+++'])) { // If *** and --- are searched for             include ('../mysql_connect.php');             $query = "SELECT username, name, website, phone, email FROM users WHERE *** = $_POST[***] AND --- = '$_POST[---]' ORDER BY name";             $result = mysql_query($query) or die(mysql_error());             while ($row = mysql_fetch_array($result, MYSQL_NUM)) {                 $un = $row[0];                 $n = $row[1];                 $w = $row[2];                 $p = $row[3];                 $e = $row[4];                 $query = "SELECT file_name FROM uploads WHERE username = '$un'";                 $result = mysql_query($query) or die(mysql_error());                 $found = FALSE;                 while ($rr = mysql_fetch_array($result, MYSQL_NUM)) {                     $file = $rr[0];                     echo "<table border=\"0\"><tr><td class=\"competing_im***s\">";                     echo "<a href=\"" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "users/$un/\"><img border=\"0\" src=\"./uploads/thumbs/th_$file\" /></a>";                     echo "</td><td class=\"competing_im***s\" style=\"text-align:left;\">";                     echo "$n<br />$w<br />$p<br />$e";                     echo "</td></tr></table>";                     $found = TRUE;                 }                 if ($found <> TRUE) {                     echo "Sorry, could not find any search terms.";                 }             }             mysql_close();         } elseif (isset($_POST['***']) && isset($_POST['---']) && isset($_POST['+++'])) { // If all are searched for             include ('../mysql_connect.php');             $query = "SELECT username, name, website, phone, email FROM users WHERE *** = $_POST[***] AND --- = '$_POST[---]' AND +++ = $_POST[+++] ORDER BY name";             $result = mysql_query($query) or die(mysql_error());             while ($row = mysql_fetch_array($result, MYSQL_NUM)) {                 $un = $row[0];                 $n = $row[1];                 $w = $row[2];                 $p = $row[3];                 $e = $row[4];                 $query = "SELECT file_name FROM uploads WHERE username = '$un'";                 $result = mysql_query($query) or die(mysql_error());                 $found = FALSE;                 while ($rr = mysql_fetch_array($result, MYSQL_NUM)) {                     $file = $rr[0];                     echo "<table border=\"0\"><tr><td class=\"competing_im***s\">";                     echo "<a href=\"" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "users/$un/\"><img border=\"0\" src=\"./uploads/thumbs/th_$file\" /></a>";                     echo "</td><td class=\"competing_im***s\" style=\"text-align:left;\">";                     echo "$n<br />$w<br />$p<br />$e";                     echo "</td></tr></table>";                     $found = TRUE;                 }                 if ($found <> TRUE) {                     echo "Sorry, could not find any search terms.";                 }             }         } else {             echo "You must search all terms.";         }     } else {         echo "No search submitted!";     }     mysql_close(); ?>
  5. Hi, So I'm writing a script that reads various data from the DB, writes and Excel file and (hopefully) redirects the user to a confirmation page after that's done.  The problem is that it either writes the files fine and doesn't redirect or redirects fine but won't write the file.  I'm using header and I'm getting a conflict. Here's the code: if ($header!="" && $data!=""){ header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=$title.xls"); header("Pragma: no-cache"); header("Expires: 0"); //header("Location: exportresult.php"); This is commented out so the file writes. print "$header"."$data"; } else { header("Location: exportproblem.php"); } I was thinking about using fwrite to write the file but that seems very cumbersome.  Any other ideas?
  6. Yeah, I saw that the minute I added the code you wanted.  Thanks for your help man.
  7. Hi, This is what is returned: 1.SELECT file_name FROM uploads WHERE file_name <> '632755314.jpg' AND file_name <> '1074829277.jpg' AND shown <> 'y' ORDER BY RAND() LIMIT 1 2.UPDATE uploads SET shown = 'y', showing = 'y' WHERE file_name = 1001626542.jpg You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jpg' at line 1
  8. I have a script that selects files from a DB and displays them side by side whenever it's run.  I get an error whenever it runs the following code though and I can't figure out what's wrong with my syntax. The error is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jpg' at line 1 Here's the code: // Select the new challenger randomly from the DB and reassign values accordingly     $query = "SELECT file_name FROM uploads WHERE file_name <> '{$winner_fn}' AND file_name <> '{$loser_fn}' AND shown <> 'y' ORDER BY RAND() LIMIT 1";     $result = mysql_query($query) or die(mysql_error());     if ($row = mysql_fetch_row($result)) {         $query = "UPDATE uploads SET shown = 'y', showing = 'y' WHERE file_name = {$row[0]}";         $result = mysql_query($query) or die(mysql_error());         $challenger_fn = $row['0'];         echo "$challenger_fn";     } else {         echo "<p>Could not select challenger!</p>";     } Thanks.
  9. Fixed the problem, I was dyslexic.  Thanks guys.
  10. First, I'd like to say thanks to all those who responded to my other two questions.  Here's one that's bizarre though. I'm getting an error on the following code: $result = @mysql_query ($query);         $row = mysql_fetch_array ($result, MYSQL_NUM);         if ($row) {             $_SESSION['date_last_in'] = $row[0];         } The error is "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" The wierd things are: a) according to php.net the syntax is CORRECT (unless I'm syslexic) and I've used this same code before with no troubles. Any ideas?
  11. Thanks for your help, but it didn't change much.  I threw in print_r($result); after the query so it looks like this: $query = "SELECT username, first_name, daily_score, agg_score, av_score, winner, times_won, win_circle, date_last_in FROM users WHERE username = '{$_SESSION['username']}'";     $result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // Do the query, show problems if any     print_r($result);     echo "Welcome {$_SESSION['first_name']}"; Now it outputs "Resource id #5".  Any ideas?  Thanks again.
  12. Hi, This should be a simple problem to fix.  What I want to do is read a bunch of user data from an SQL table and print it.  I've checked my syntax on PHP.net, I've used similar code before....I have no idea what is going wrong and I think it's a case of cognitive dissonance. There are no errors returned upon running the script so I'm kind of at a loss.  Any help would be appreciated, thanks. Here's the code: <?php # the user index page     require_once ('../includes/config.inc');     $page_title = "Welcome Home";     include_once ('../includes/header.html');     require_once ('../not_web/mysql_connect.php');     $query = "SELECT username, first_name, daily_score, agg_score, av_score, winner, times_won, win_circle, date_last_in FROM users WHERE username = '{$_SESSION['username']}'";     $result = @mysql_query($query); // Do the query         echo "Welcome {$_SESSION['first_name']}";     [color=orange]// Here I used both just to check that I wasn't crazy but originally I was using MYSQL_NUM with correct syntax[/color]     while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {         echo $row[0], '<br />';         echo $row["first_name"], '<br />';         echo $row[2], '<br />';         echo $row[3], '<br />';         echo $row[4], '<br />';         echo $row[5], '<br />';         echo $row[6], '<br />';         echo $row[7], '<br />';         echo $row[8], '<br />';     }     mysql_free_result($result);     mysql_close();     include_once('../includes/footer.html'); ?> Thanks again.
  13. Thanks guys, that helped, but I have one quick question.  When I read the data from the DB, it seems like the only data that's being read is the first two table rows (first_name) and (username).  Have any idea why that might be?  Also, I use a while loop to print out all the data.  I've used this same code before and it worked fine but for some reason now it seems to not print anyhting.  I don't get any errors when I run the code either. Here is the script: <?php # the user index page     require_once ('../includes/config.inc');     $page_title = "Welcome Home";     include_once ('../includes/header.html');     require_once ('../not_web/mysql_connect.php');     $query = "SELECT first_name, username, daily_score, agg_score, av_score, winner, times_won, win_circle, date_last_in FROM users WHERE username = '{$_SESSION['username']}'";     $result = @mysql_query($query);     $bg = '#eeeeee';  // This is so that each iteration of the while has a different background color.     echo "Welcome {$_SESSION['first_name']}";     print_r($_SESSION); //This only prints the first_name and username nothing else     while ($row = mysql_fetch_array($result, MYSQL_NUM)) {  //This does not return any errors, but also does not return anything.         $bg = ($bg == '#eeeeee' ? '#ffffff' : '#eeeeee');         echo '<span style="background:', $bg, ';">', stripslashes($row[0]), '</span><br />';     }     mysql_free_result($result);     mysql_close();     include_once('../includes/footer.html'); ?> Thanks again for your help.
  14. Hi, I'm trying to write a script where after loggin in, some of the stored data of a user is read from a SQL table and then printed to their page.  So it has to be dynamic to whoever is logged in.  I'm new at this so any help would be greatly appreciated. The query I have is: $query = "SELECT username, daily_score, agg_score, av_score, winner, times_won, win_circle, date_last_in FROM users WHERE username = $_SESSION['username']"; I guess it's a problem with the qotes...but I've tried different combos with escaping and I can't figure it out.  Of course, maybe how I've written it isn't allowed? Thanks in advance.
×
×
  • 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.