Jump to content

kentopolis

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

kentopolis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I don't know that my question is very clear. So here it is. Why does this script continue to show the same results when you click "next 5 results >>", it should show me the next set of results but instead it shows the same thing again. I can't figure it out, please help...
  2. I am having an issue with this script <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=5; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","pets_puppylister","fiveft12"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("pets_puppylist") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from dogs where ptype like \"%$trimmed%\" AND pshow = 'y' order by did desc"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; } // determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["ptype"]; $email = $row["email"]; $did = $row["did"]; /////////////////////////// $gender = $row["gender"]; $price = number_format($row["price"], 2,'.',','); $qty = $row["qty"]; $dob_month = $row["dob_month"]; $dob_day = $row["dob_day"]; $p_pound = $row["p_pound"]; $p_oz = $row["p_oz"]; $p_date = $row["p_date"]; $link = $row["link"]; $p_num = $row["p_num"]; $address = $row["address"]; $comment = $row["comment"]; $avail_month = $row["avail_month"]; $avail_day = $row["avail_day"]; ////////////////////////////// echo "<p><span class=\"style52\">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </span><p><span class=\"styledogsforsale\">$title for Sale - ID #$did</span><br><br>D.O.B. - $dob_month $dob_day<br>$qty $gender $title<br><span class=\"style40\">Price: $$price<br>Ad Expires $avail_month $avail_day<br>$Comment</span><p><span class=\"styledogsforsale\">Contact Information:</span><br>$address<br><a href=mailto:$email>$email</a><br>$p_num <br><a href=\"$link\" target=\"_blank\">$link</a> <br>"; if(file_exists('admin/uploads/'.$did.'.jpg')){ echo "<a href=\"admin/uploads/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesize.php?did=$did&h=100\" border=\"0\"></a> "; }else{ echo ""; }; if(file_exists('admin/uploads/a/'.$did.'.jpg')){ echo "<a href=\"admin/uploads/a/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesizea.php?did=$did&h=100\" border=\"0\"></a> "; }else{ echo ""; }; if(file_exists('admin/uploads/b/'.$did.'.jpg')){ echo "<a href=\"admin/uploads/b/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesizeb.php?did=$did&h=100\" border=\"0\"></a> "; }else{ echo ""; }; if(file_exists('admin/uploads/c/'.$did.'.jpg')){ echo "<a href=\"admin/uploads/c/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesizec.php?did=$did&h=100\" border=\"0\"></a> "; }else{ echo ""; }; " <p>"; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <span class=\"styledogsforsale\"><a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 5 Results</a></span>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give link $news=$s+$limit; echo "<p> <span class=\"styledogsforsale\"><a href=\"$PHP_SELF?s=$news&q=$var\">Next 5 Results >></a></span>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p><span class=\"style52\">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </span><p>Showing results $b to $a of $numrows</p>"; ?> I have gotten everything to work on it, except, when it goes to create a new page with the next set of results, it turns up the first page of results. I have gone through the code several times and can't seem to get anywhere. Here is a sample search using the script http://www.petsforsalecs.com/search.php?q=a&Submit=Search+Pets You can visit to see what it is doing. Thank you so much! I think specifically the issue is in this part somewhere, but I just don't know enough about the language to figure it out: $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <span class=\"styledogsforsale\"><a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 5 Results</a></span>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give link $news=$s+$limit; echo "<p> <span class=\"styledogsforsale\"><a href=\"$PHP_SELF?s=$news&q=$var\">Next 5 Results >></a></span>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p><span class=\"style52\">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </span><p>Showing results $b to $a of $numrows</p>"; ?> Here is a complete working version of the script http://www.designplace.org/search.php?s=0&q=p which I got from http://www.designplace.org/scripts.php?page=1&c_id=25 and have manipulated. Thanks for all your help, this forum has been a lifesaver!
  3. Thank you for all your help, I got this to work: if(file_exists('admin/uploads/'.$did.'.jpg')){ echo "<a href=\"admin/uploads/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesize.php?did=$did&h=100\" border=\"0\"></a>"; }else{ echo ""; };
  4. You are correct about the images being uploaded, I am not currently storing them in the database. Hmmm.... I will look into that idea...
  5. Does that snippet work? here it is seperate from the other code: .(admin/uploads/c/$did.jpg > "")?'<a href="admin/uploads/c/$did.jpg" target="_blank"><img src="admin/imagesizec.php?did=$did&h=100" border="0"></a>':'no picture to display'. is there a way to make it work?
  6. Tried the if statment redarrow and got the following error "Parse error: syntax error, unexpected T_IF in /home/pets/public_html/search_test.php on line 239". I searched for a solution, have been searching, found this (I am using a cross section of the code so you can see where I inserted it) <?"- - - - - </span><p><span class=\"styledogsforsale\">$title for Sale - ID #$did</span><br>".(admin/uploads/c/$did.jpg > "")?'<a href="admin/uploads/c/$did.jpg" target="_blank"><img src="admin/imagesizec.php?did=$did&h=100" border="0"></a>':'no picture to display'."<br>D.O.B. - $dob_month $dob_day<br>$qty $gender $title<br>"?> But it returns an error saying I'm dividing by "0". I appreciate all the ideas, cause I am stumped Here is all of my code: <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","pets_puppylister","fiveft12"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("pets_puppylist") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from dogs where ptype like \"%$trimmed%\" AND pshow = 'y' order by did desc"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo ""; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["ptype"]; $email = $row["email"]; $did = $row["did"]; /////////////////////////// $gender = $row["gender"]; $price = number_format($row["price"], 2,'.',','); $qty = $row["qty"]; $dob_month = $row["dob_month"]; $dob_day = $row["dob_day"]; $p_pound = $row["p_pound"]; $p_oz = $row["p_oz"]; $p_date = $row["p_date"]; $link = $row["link"]; $p_num = $row["p_num"]; $address = $row["address"]; $comment = $row["comment"]; $avail_month = $row["avail_month"]; $avail_day = $row["avail_day"]; ////////////////////////////// echo "<span class=\"style52\">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </span><p><span class=\"styledogsforsale\">$title for Sale - ID #$did</span><br>".(admin/uploads/c/$did.jpg > "")?'<a href="admin/uploads/c/$did.jpg" target="_blank"><img src="admin/imagesizec.php?did=$did&h=100" border="0"></a>':'no picture to display'."<br>D.O.B. - $dob_month $dob_day<br>$qty $gender $title<br><span class=\"style40\">Price: $$price<br>Ad Expires $avail_month $avail_day<br>$Comment</span><p>Contact Information:</strong><br> <strong>Phone Number:</strong> $p_num <br><strong>Address:</strong> $address<br> <strong>Email:</strong> <a href=mailto:$email>$email</a><br><a href=\"$link\" target=\"_blank\">$link</a> <br> <p>"; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>&nbsp "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p><span class=\"style52\">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </span><p>Showing results $b to $a of $numrows</p>"; ?>
  7. I am using a HTML search form to give me the following result. I can get everything to work, even get it to display images that are associated with particular search term, but can't figure out how to keep it from displaying that annoying little "There's not image here image" that explorer shows, the one with box and red "x". I know that an if statement would do the trick, but I can't do "if's" inside of the "echo" is it possible to accomplish this? How? Thank you so much, the expertise on this forum has been tremendously helpful! while ($row= mysql_fetch_array($result)) { $title = $row["ptype"]; $email = $row["email"]; $did = $row["did"]; /////////////////////////// $gender = $row["gender"]; $price = number_format($row["price"], 2,'.',','); $qty = $row["qty"]; $dob_month = $row["dob_month"]; $dob_day = $row["dob_day"]; $p_pound = $row["p_pound"]; $p_oz = $row["p_oz"]; $p_date = $row["p_date"]; $link = $row["link"]; $p_num = $row["p_num"]; $address = $row["address"]; $comment = $row["comment"]; $avail_month = $row["avail_month"]; $avail_day = $row["avail_day"]; ////////////////////////////// echo "<span class=\"style52\">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </span><p><span class=\"styledogsforsale\">$title for Sale - ID #$did</span><br> <a href=\"admin/uploads/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesize.php?did=$did&h=100\" border=\"0\"></a> <a href=\"admin/uploads/a/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesizea.php?did=$did&h=100\" border=\"0\"></a> <a href=\"admin/uploads/b/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesizeb.php?did=$did&h=100\" border=\"0\"></a> <a href=\"admin/uploads/c/$did.jpg\" target=\"_blank\"><img src=\"admin/imagesizec.php?did=$did&h=100\" border=\"0\"></a><br>D.O.B. - $dob_month $dob_day<br>$qty $gender $title<br><span class=\"style40\">Price: $$price<br>Ad Expires $avail_month $avail_day<br>$Comment</span><p>Contact Information:</strong><br> <strong>Phone Number:</strong> $p_num <br><strong>Address:</strong> $address<br> <strong>Email:</strong> <a href=mailto:$email>$email</a><br><a href=\"$link\" target=\"_blank\">$link</a> <br> <p>"; $count++ ; } $currPage = (($s/$limit) + 1);
  8. Hey everyone, I am really new to PHP, I have a script that is working for an individual to update a dog ad on this site I built. What I would like to have happen is not only for the data to post to the MySQL, but also for it to email me and tell me that someone has placed an ad. I know this is probably extra simple, but I am dumb. Please, if you could, just tell me how it would work in the script I have, what I need to ad where... Thank you so much for your help, the people on this forum have already taught me a lot! Here is my code, thank you so much! <? include('includes/includes.php'); if($_POST['add_puppy']){ $p_date = $_POST['month']."/".$_POST['day']."/".$_POST['year']; if(isset($_POST['pshow'])){ $pshow = 'y'; }else{ $pshow = 'n'; } $sql = "insert into dogs(ptype,pstatus,avail_month,avail_day,dob_month,dob_day,qty,gender,p_pound,p_oz,p_date,price,link,p_num,address,email,name,comment,pshow)values("; $sql .= "'$_POST[ptype]',"; $sql .= "'$_POST[pstatus]',"; $sql .= "'$_POST[avail_month]',"; $sql .= "'$_POST[avail_day]',"; $sql .= "'$_POST[dob_month]',"; $sql .= "'$_POST[dob_day]',"; $sql .= "'$_POST[qty]',"; $sql .= "'$_POST[gender]',"; $sql .= "'$_POST[p_pound]',"; $sql .= "'$_POST[p_oz]',"; $sql .= "'$p_date',"; $sql .= "'$_POST[price]',"; $sql .= "'$_POST[link]',"; $sql .= "'$_POST[p_num]',"; $sql .= "'$_POST[address]',"; $sql .= "'$_POST[email]',"; $sql .= "'$_POST[name]',"; $sql .= "'$_POST[comment]',"; $sql .= "'$pshow')"; mysql_query($sql); $top = mysql_fetch_array(mysql_query("select did from dogs order by did desc limit 1")); if ($_FILES['imagefile']['type'] == "image/pjpeg" || $_FILES['imagefile']['type'] == "image/jpeg"){ copy ($_FILES['imagefile']['tmp_name'], "admin/uploads/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile']['name'].")"; } ///////////// if ($_FILES['imagefile2']['type'] == "image/pjpeg" || $_FILES['imagefile2']['type'] == "image/jpeg"){ copy ($_FILES['imagefile2']['tmp_name'], "admin/uploads/a/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile2']['name'].")"; } //////////////// if ($_FILES['imagefile3']['type'] == "image/pjpeg" || $_FILES['imagefile3']['type'] == "image/jpeg"){ copy ($_FILES['imagefile3']['tmp_name'], "admin/uploads/b/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile3']['name'].")"; } //////////////// if ($_FILES['imagefile4']['type'] == "image/pjpeg" || $_FILES['imagefile4']['type'] == "image/jpeg"){ copy ($_FILES['imagefile4']['tmp_name'], "admin/uploads/c/$top[did].jpg") or die ("Error Uploading: Image Not Copied"); } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile4']['name'].")"; } //////////////// header("Location: thanks.html"); exit(); } if($_POST['cancel']){ header("Location: cancel.html"); exit(); } ?> <html> <head> <title><?=$company?> Add Pet For Sale Panel</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .style9 { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } .style12 {font-size: 12px} .style14 {font-size: 12px; color: #FF0000; } --> </style> </head> <body> <table width="100%"> <tr> <td align="center"><font size="4" face="Arial, Helvetica, sans-serif"><b> <?=$company?> Admin Panel</b></font></td> </tr> <tr> <td align="center"> <span class="style9"> <!-- Start Content --> <br> <br> </span> <form action="add_user.php" method="post" enctype="multipart/form-data" class="style9"> <table width="780" cellpadding="2" BORDER=1 bordercolor="#C6C1D7" cellspacing="0"> <tr bgcolor="#C6C1D7"> <td align="center" colspan="100%"><strong>Add New Pet</strong></td> </tr> <tr> <td width="139" align="right"><strong>Pets Type :</strong> </td> <td width="627"><input name="ptype" type="text" size="30"> <span class="style12">(example: Yorkie) </span></td> </tr> <tr> <td align="right"><strong>Your Name :</strong> </td> <td><input name="name" type="text" id="name" size="30"></td> </tr> <tr> <td align="right"><strong>Phone #:</strong> </td> <td><input name="p_num" type="text" id="p_num" size="30"></td> </tr> <tr> <td align="right"><strong>Address :</strong> </td> <td><input name="address" type="text" id="address" size="30"></td> </tr> <tr> <td align="right"><strong>Email :</strong> </td> <td><input name="email" type="text" id="email" size="30"></td> </tr> <tr> <td align="right"><strong>Gender :</strong></td> <td><select name="gender"> <option value="Male">Male</option> <option value="Female">Female</option> </select></td> </tr> <tr><td align="right"><strong>Price :</strong></td> <td><input name="price" type="text" size="10"> <font face="Arial, Helvetica, sans-serif"><span class="style12">(p_nums only - NEVER USE A $ - IT'S PUT IN AUTOMATICALLY) </span></font></tr> <tr><td align="right"><strong>Date of Birth :</strong> </td> <td>Month: <input type="text" name="dob_month" size="10"> (example: June) Day: <input type="text" name="dob_day" size="2"></td> </tr> <tr> <td align="right"><strong>Pets Weight :</strong></td> <td><input type="text" name="p_pound" size="2"> Pounds <input type="text" name="p_oz" size="2"> Ounces on date: <input type="text" name="month" size="1"> / <input type="text" name="day" size="1"> / <input type="text" name="year" size="1"></td> </tr> <tr><td align="right"><strong>Comments :</strong></td> <td><textarea name="comment" rows="3" cols="40"></textarea></td> </tr> <tr> <td align="right"><strong>Link:</strong></td> <td><font size="2"> <font face="Arial, Helvetica, sans-serif"> <input name="link" type="text" size="32"> </font></font> <font size="1" face="Arial, Helvetica, sans-serif">(format http://www.yourlink.com) </font></td> </tr> <tr> <td align="right"><strong>Pets Image 1:</strong> </td> <td><input name="imagefile" type="file" size="40"></td> </tr> <tr> <td align="right"><strong>Pets Image 2:</strong></td> <td><input name="imagefile2" type="file" size="40"></td> </tr> <tr> <td align="right"><strong>Pets Image 3:</strong></td> <td><input name="imagefile3" type="file" size="40"></td> </tr> <tr> <td align="right"><strong>Pets Image 4:</strong></td> <td><input name="imagefile4" type="file" size="40"></td> </tr> <tr><td align="right"> </td> <td> <input type="submit" name="add_puppy" value="Add New Pet"> <input type="submit" name="cancel" value="Cancel"> </td> </tr> </table> </form> <span class="style9"> <!-- End Content --> </span></td> </tr> </table> </body> </html>
  9. Sorry, if I'm not clear, when I try uploading an image from a url I get an error message. It uploads fine from a computer (through browsing to find the image), but can't get it to work with a URL. The person I am using this for wants to be able to copy their url that was created using a different form and insert it here instead of having to download the image and then reupload it to another file... Maybe you need to see the entire script?
  10. Hi all, I have this script for uploading images from a computer, but I need to be able to upload using URL's as well, here is the portion of the script I think needs to change, if you need more let me know... Thanks for your help, I am quite a newbie at PHP... }elseif($_POST['upload']){ $page = $_POST['page']; if ($_FILES['imagefile']['type'] == "image/pjpeg" || $_FILES['imagefile']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile']['tmp_name'], "uploads/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile']['name'].")"; } /////////////////////////////// }elseif($_POST['upload2']){ $page = $_POST['page']; if ($_FILES['imagefile2']['type'] == "image/pjpeg" || $_FILES['imagefile2']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile2']['tmp_name'], "uploads/a/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile2']['name'].")"; }/////////////////////////////// }elseif($_POST['upload3']){ $page = $_POST['page']; if ($_FILES['imagefile3']['type'] == "image/pjpeg" || $_FILES['imagefile3']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile3']['tmp_name'], "uploads/b/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile3']['name'].")"; }//////////////////////////////////// }elseif($_POST['upload4']){ $page = $_POST['page']; if ($_FILES['imagefile4']['type'] == "image/pjpeg" || $_FILES['imagefile4']['type'] == "image/jpeg"){ if(copy ($_FILES['imagefile4']['tmp_name'], "uploads/c/$_POST[did].jpg")){ // do nothing }else{ $err = "Error Uploading: Image Not Copied"; } } else { $err = "File not copied, Wrong Filetype (".$_FILES['imagefile4']['name'].")"; }
  11. I am having trouble with this script.  I am trying to create an install file that will install my database and tables.  I would like the database name to and host name to be read from a text file name host.txt.  The honest truth is, I don't know very much about php at all.  I'm sure there is an easy answer, maybe it is just "this can't be done".  But I have tried every configuration I can think of and I honestly just need some help.  I can get ti to work if I manually enter the host name, as below.  I also have the script working to read the file, I just can't seem to integrate the two...  Here is the script as is working without reading the text file into the host names (I have not provided all of the script, i.e. the tables section, because the other part is working great... <?php include 'config.php'; include 'opendb.php'; //begin get host name need to figure out how to install it into script $fp = @fopen("host.txt", "rb") or die("Couldn't open file"); $data = fread($fp, filesize($fp)); while(!feof($fp)) { $data .= fgets($fp, 1024); } fclose($fp); $values = explode("\r\n", $data); echo "" . $values[0] . "puppylist"; //end get hostname $query  = 'CREATE DATABASE hostname_puppylist'; $result = mysql_query($query); mysql_select_db('hostname_puppylist'); or die('Cannot select database, install db: puppylist dbu: puppylister'); $query = $query = 'CREATE TABLE dogs2( '. .... here is the section I am having trouble with... $query  = 'CREATE DATABASE hostname_puppylist'; $result = mysql_query($query); mysql_select_db('hostname_puppylist'); or die('Cannot select database, install db: puppylist dbu: puppylister'); I want it to look like this... $query  = 'CREATE DATABASE echo "" . $values[0] . "_puppylist"'; $result = mysql_query($query); mysql_select_db(echo "" . $values[0] . "_puppylist"); or die('Cannot select database, install db: puppylist dbu: puppylister'); .... I know I've got it all wrong, is there anyone who can help me?
  12. Hi, I have this puppy for sale classifieds program that I am trying to introduce some javascript too, the problem is when I use "{", "}" I get problems, errors.  I tried putting my javascript in a .js file and running it externally, but then nothing comes up.  the problem, is this javascript is designed to create multiple image (banner ad) rotations on one page, so I am not sure how to call an individual instance of the javascript.  visit [url=http://www.wagnpaws.com]www.wagnpaws.com[/url] this is where the banners should be showing up but aren't.  [url=http://www.wagnpaws.com/banner_ads.html]www.wagnpaws.com/banner_ads.html[/url] is an example of the script working outside of the program inside of the html.  My javascript file is found at [url=http://www.wagnpaws.com/rotate.js]www.wagnpaws.com/rotate.js[/url].  If anyone can help, I would really appreciate it, or if you have any ideas of a better way of doing this...  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.