Jump to content

imarockstar

Members
  • Posts

    263
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

imarockstar's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. I am just testing now .. and I will add all the sql inj. stuff later ... i updated the code and now I am getting 2 errors then I the var i pass is empty (zip) <div class=""> <?php // if the submit button has been clicked then we perform the search if (isset($_POST['submitsearch'])) { $zip = $_POST['zip']; $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $sql="SELECT * FROM shows WHERE zip = ".$_POST['zip'].""; $result=mysql_query($sql) or trigger_error("MySQL Failed: " . mysql_error()); $count = mysql_num_rows($result); if ( $count == '' ) { echo "Sorry no shows were found, please try again"; } else { echo "Search Results"; while($rows=mysql_fetch_array($result)){ echo $rows['venue']; echo "<br>"; } // search results end } // if post is empty else } // post if end ?> </div> my error : Notice: MySQL Failed: 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 in /home/tourzag/public_html/stfo_scripts.php on line 60 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/stfo_scripts.php on line 61 Sorry no shows were found, please try again although when i put a zipcode into the form, the query worked fine and it returns the data.
  2. updated code <div class=""> <?php // if the submit button has been clicked then we perform the search if (isset($_POST['submitsearch'])) { $zip = $_POST['zip']; $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $sql="SELECT * FROM shows WHERE zip = ".$_POST['zip'].""; $result=mysql_query($sql); $count = mysql_num_rows($sql); echo $count; if ( $count == '' ) { echo "Sorry no shows were found, please try again"; } else { echo "Search Results"; while($rows=mysql_fetch_array($result)){ echo $rows['venue']; echo "<br>"; } // search results end } // if post is empty else } // post if end ?> </div> <p>Search for shows, this will be used for bands who will be on the road and need to book a show on a certain date in a certain city.</p> <br> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > Zipcode: <input type="text" name="zip" > <br> Date Needed: <?php include("modules/form_date.php"); ?> <br> <input type="submit" name="submitsearch" value="Find Show"> </form> error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/stfo_scripts.php on line 63 Sorry no shows were found, please try again Search for shows, this will be used for bands who will be on the road and need to book a show on a certain date in a certain city. im trying to count the rows, and if the rows come back empty then it displays an error .. this is line 63 $count = mysql_num_rows($sql); not sure why i am getting this ..
  3. this is my code <div class=""> <?php // if the submit button has been clicked then we perform the search if (isset($_POST['submitsearch'])) { $zip = $_POST['zip']; $day = $_POST['day']; $month = $_POST['month']; $year = $_POST['year']; $result = mysql_query ("SELECT * FROM shows WHERE zip = '75034' " or die(mysql_error())); $count = mysql_num_rows($result); echo $count; if ( $count == '' ) { echo "Sorry no shows were found, please try again"; } else { echo "Search Results"; while($rows=mysql_fetch_array($result)){ echo $rows['venue']; echo "<br>"; } // search results end } // if post is empty else } // post if end ?> </div> <p>Search for shows, this will be used for bands who will be on the road and need to book a show on a certain date in a certain city.</p> <br> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > Zipcode: <input type="text" name="zip" > <br> Date Needed: <?php include("modules/form_date.php"); ?> <br> <input type="submit" name="submitsearch" value="Find Show"> </form> this is my error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/stfo_scripts.php on line 60 Sorry no shows were found, please try again i cant figure it out ... why its throwing that error ..
  4. ok either I am totally stupid or I explained my problem incorrectly .. um r both lol .. I am displaying my date this way via php : echo $rows['sh_date']; which is displayed as this : 2010-01-10 In php is there a function that takes 2010-01-10 and figures out what day of the week that is and then can return the new value to be displayed as : Wednesday January 10 2010 That link you sent me is confusing the hell out of me .. sorry for the stupidity .. b
  5. I did see that, however my problem is that i have over 500 records in my DB with the date stored like this : 2010-01-10. I didn't want to have to go add the day of the week to each of those records. Was not sure if there was a function that would somehow get the dat of the week based on 2010-01-10.
  6. I need the MYSQL date format reformatted .. which the below does fine. But I was wandering if there was a function to automatically get the day of the week to be outputted as well ? <? $date = $rows['sh_date']; $newdate = explode("-", $date); $showdate = "".$newdate[1].".".$newdate[2].".".$newdate[0].""; echo $showdate; ?>
  7. does not seem to work ... even if i select an image .. it still passes the image upload .. if ($_POST['addband']) { if (is_uploaded_file ($_FILES['bandpik']['name'])){ $imagename = $_FILES['bandpik']['name']; $source = $_FILES['bandpik']['tmp_name']; $target = "../bandpiks/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "../bandpiks/" . $imagepath; //This is the new file you saving $file = "../bandpiks/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "../bandpiks/sml_" . $imagepath; //This is the new file you saving $file = "../bandpiks/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='../bandpiks/".$imagepath."'><br>"; echo "Thumbnail: <img src='../bandpiks/sml_".$imagepath."'>"; } //else { $imagepath = 'g_no_pik_yet.png'; } else { echo "woops, no image"; }
  8. I am trying to upload an image .. but if someone does not select an image i need the script to do something else .. this is what i have .. if ($_POST['addband']) { if (isset ($_FILES['bandpik'])){ $imagename = $_FILES['bandpik']['name']; $source = $_FILES['bandpik']['tmp_name']; $target = "../bandpiks/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "../bandpiks/" . $imagepath; //This is the new file you saving $file = "../bandpiks/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 500; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "../bandpiks/sml_" . $imagepath; //This is the new file you saving $file = "../bandpiks/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 80; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; echo "Large image: <img src='../bandpiks/".$imagepath."'><br>"; echo "Thumbnail: <img src='../bandpiks/sml_".$imagepath."'>"; } else { echo "wooops"; } the actual image upload works great .. but if someone does not select an image from the form, the script still runs .... i thought i had fixed that with the if (isset ($_FILES['bandpik'])){ ... ut i was wrong .. any suggestions ? thanks
  9. I have a script that I can add a text box when a user clicks ADD .. <script type="text/javascript"> var intTextBox=0; //FUNCTION TO ADD TEXT BOX ELEMENT function addElement() { intTextBox = intTextBox + 1; var contentID = document.getElementById('contentx'); var newTBDiv = document.createElement('div'); newTBDiv.setAttribute('id','strText'+intTextBox); newTBDiv.innerHTML = "Text "+intTextBox+": <input type='text' name='jobreq' id='" + intTextBox + "' name='" + intTextBox + "'/>"; contentID.appendChild(newTBDiv); } //FUNCTION TO REMOVE TEXT BOX ELEMENT function removeElement() { if(intTextBox != 0) { var contentID = document.getElementById('contentx'); contentID.removeChild(document.getElementById('strText'+intTextBox)); intTextBox = intTextBox-1; } } </script> <p><a href="javascript:addElement();" >Add</a> <a href="javascript:removeElement();" >Remove</a></p> <div id="contentx"></div> this works great .. but I need to ad "+ 1" to each box added ... example ... for everytime a user clicks on ADD i need it to do this .. <input type='text' name='jobreq' id='" + intTextBox + "' name='" + intTextBox + "'/> user clicks ADD again <input type='text' name='jobreq2' id='" + intTextBox + "' name='" + intTextBox + "'/> <input type='text' name='jobreq3' id='" + intTextBox + "' name='" + intTextBox + "'/> <input type='text' name='jobreq4' id='" + intTextBox + "' name='" + intTextBox + "'/> <input type='text' name='jobreq5' id='" + intTextBox + "' name='" + intTextBox + "'/> so each time the user clicks add, we want to add one to the NAME tag: name='jobreq" .. can anyone help me with this ? thanks bobby
  10. I had a question and the guys on this forum quickly helped me out .. so here is the final site ... its nothing but a stupid form that will generate your mysql post variables, input, update and result code and you can cut and paste it .. ya there is like no css or anything and its ugly as a fat girl on prom night .. but it works .. and i am lazy and i hate re doing code .. so thats why i made it .. hah http://comtechnews.org/mysqlform/
  11. I am outputting some pho code .. and I want to display the source code so people can copy and paste it .... not really wanting to use a TEXTAREA box .... any ideas ?
  12. this is what i got .. but it not working .. <?php $a = explode(',', $vary); $c = count($a); $x = 1; foreach ($a as $v) { $comma = ($c == $x) ? "" : ","; echo "".$v."".$comma; } ?> ) <br>
  13. I have a script that echos out sample code .. and it works fine .. but when it prints each block of code out ... there is a comma at the end of each array .. i know why it there .. but i dont know a trick to get it off there .. here is an example ... if there are 5 form fields, each asking for a variable name and the user enters this : name email phone city state then the array is : name,email,city,state, you can see that there is a COMMA after state, and you can see below that I am putting it there so the code output it valid. However i dont need the code on the last post entry. is there a way i can take that out ? here is my code : $tablename = $_POST['tablename']; $header = $_POST['header']; if ( isset($_POST['v']) ) { $vary = implode(',', $_POST['v']); } else { $vary = ""; } ?> <code clss="getcode"> <p> <?php $a = explode(',', $vary); foreach ($a as $v) { echo "$".$v."=\$_POST['" . $v . "']; <br>"; } ?> </p> </code> <h4 class="codehead">Insert Code</h4> <code clss="getcode"> <p> $sql="INSERT INTO <?php echo $_POST['tablename'];?> ( <?php $a = explode(',', $vary); foreach ($a as $v) { echo "".$v.","; } ?> ) <br> VALUES ( <?php $a = explode(',', $vary); foreach ($a as $v) { echo "'".$v."',"; } ?> ); </p> </code> <h4 class="codehead">Update Code</h4> <code clss="getcode"> <p> mysql_query("UPDATE merch SET <?php $a = explode(',', $vary); foreach ($a as $v) { echo "".$v."='".$v."',"; } ?> "); </p> </code> <code clss="getcode"> <p> $result = mysql_query($sql) or die("ERROR: " . mysql_error() . "SQL: " . $sql); <br> header("Location: <?php echo $_POST['header'];?>"); </p> <br> </code>
  14. I have a website that has a DB of alot of rock venues in the usa .. I need to display all the venues sorted out by there state ... in each state i need to have all the venues of that state listed ... the code i have (that is not working) is : <?php $sql="SELECT * FROM venues WHERE vstate != '' GROUP BY vstate "; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ ?> <? echo $rows['vname']; ?> - <? echo $rows['vstate']; ?><bR> <?php $sql2="SELECT * FROM venues WHERE vstate = ".$rows['vstate']." "; $result2=mysql_query($sql2); // Start looping rows in mysql database. while($rows2=mysql_fetch_array($result2)){ ?> <? echo $rows2['vname']; ?> *** <br> <?php } ?> <? } ?> the error I am getting is this : Last Supper Club - WA Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 Cafe Du Nord - CA Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 Great Scott - MA Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 the machine shop - MN Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 Halligans - SC Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 Club Dada - TX Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 Club Mantra - WA Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/tourzag/public_html/view_venues.php on line 37 looks like it is displaying 1 venue from each state but wont list the other venues of that state .. any ideas ?
×
×
  • 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.