
Janj
Members-
Posts
25 -
Joined
-
Last visited
Everything posted by Janj
-
Turns out I was requesting the wrong page.I forgot to make sure that on the first time, it checked to see if status wasn't "done," fixed it. Changed line 40 to if($_GET['id']=="" && $_GET['status']=="") and line 95 to else if ($_GET['id']=="" && $_GET['status']=="done") And I turned the $result line "back on." My error is: No database selected in /hermes/waloraweb018/b1141/as.jansaviation/acp/changearticle.php on line 126. Which I only get from the result line. At the top, I already put mysql_select_db("newsdb", $con); so I don't know why it's telling me 'no database selected.' I tried this suggestion of prefixing the table with the database (changing UPDATE articles to UPDATE newsdb.articles) Well, that just worked. Thanks so much!
-
Off, turned it on. Now I see this: Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /hermes/waloraweb018/b1141/as.jansaviation/acp/changearticle.php on line 42 Fatal error: Query Failed! SQL: UPDATE articles SET [here goes a looot of stuff, what was typed in] WHERE artnum='1' - Error: No database selected in /hermes/waloraweb018/b1141/as.jansaviation/acp/changearticle.php on line 127 $sql = "UPDATE articles SET art_title='".$art_title."', art_image='".$art_image."', image_caption='".$image_caption."', image_src='".$image_src."', image_src_location='".$image_src_location."', article ='".$article."' WHERE artnum='".$_POST['ID']."'"; $result=mysql_query($sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysql_error(), E_USER_ERROR); //mysql_query($sql); echo "Article edited."; If I comment out the $result line but uncomment the mysql_query line I get this: Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /hermes/waloraweb018/b1141/as.jansaviation/acp/changearticle.php on line 42 Article edited. Here's my document: http://pastebin.com/Uk04mgui
-
Back on a computer. Changed it back to mysql, still the same. I also changed error reporting from E_ALL & ~E_NOTICE to E_ALL. Nothing yet. The bottom of the source shows this: <div class="big">CHANGE ARTICLE</div> <!--Do not insert anything before this line--> Right after which comes the code, then comes the closing div, body, and html, all of which are not displayed. So when $result=mysql_query($sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysql_error(), E_USER_ERROR); appears, it prevents anything past it from loading.
-
Here it is, my attempt: $sql = "UPDATE articles SET art_title='".$art_title."', art_image='".$art_image."', image_caption='".$image_caption."', image_src='".$image_src."', image_src_location='".$image_src_location."', article ='".$article."' WHERE artnum=".$_POST['ID'].""; $result=mysqli_query($sql) or trigger_error("Query Failed! SQL: $sql - Error: ".mysqli_error(), E_USER_ERROR); //mysql_query("UPDATE articles SET art_title='".$art_title."', art_image='".$art_image."', image_caption='".$image_caption."', image_src='".$image_src."', image_src_location='".$image_src_location."', article ='".$article."' WHERE artnum=".$_POST['ID'].""); echo "Article edited."; But the page just doesn't load it. Not even "Article edited"
-
Well I knew the query failed because nothing happened, but I don't know how to check it... Looked for an article on update syntax. Found one from MySQL and a million questions about it. I changed all the \"s to 's, put the WHERE after the SET, and removed the quotes around $_POST['ID'] I'm on my iPad right now so testing isn't as easy as it is on the computer so I'll wait for tomorrow to continue this.
-
I created a script that is supposed to update some values in a database. However, it won't change anything. This is my code: //Edit article mysql_query("UPDATE articles WHERE artnum=\"".$_POST['ID']."\" SET art_title=\"".$art_title."\", art_image=\"".$art_image."\", image_caption=\"".$image_caption."\", image_src=\"".$image_src."\", image_src_location=\"".$image_src_location."\", article =\"".$article."\""); echo "Article edited."; I know that it is executed because it is in an if statement and I can see the "Article edited." But I've tried altering the actual query various times, changing the order of the WHERE and SET, etc, using mysqli_query, and nothing has worked so far.I've checked all my variables, they all exist and I can echo each one of them. I have no idea what to do.
-
It seems AdBlock was blocking it. Thanks!
-
There's something wrong on my site... I'm implementing ads, so I'm testing it out. I created an image saying that 'you can advertise now' or something like that. However, the image is in my /img/ads/ folder. I've tried changing the name of the image, but it still won't display. Here's the code: <a href="http://[redacted]/advertising.php"><img src="img/ads/jansav_ad.png"></a> I tried fixing the code. I put it in the TryIt Editor and the image still wouldn't display.I thought it would be something wrong with the image, but strangely, I can still see it on my iPad and iPod. Here's the picture: [redacted] Or since it likely doesn't show up, it's here: [redacted] I never knew something like this can happen. I uploaded the image a few days ago, and thought it might take a while (sometimes it takes a few hours until I can see it) it's been too long.
-
Solved — went into the php.ini and changed the session save location.
-
Yeah, it's not passing the variables on. I altered check.php: if(!isset($_SESSION['loggedin'])) { echo "error "; echo session_id(); exit; } When I go to newarticle.php, I get an error (because apparently loggedin isn't set) but I do get the session id. It's strange, I would'nt expect to get one and not the other. Are they (the variables) not being saved?
-
Hey. Sorry I haven't been on in a while, I was really sick and I couldn't get to this. Just phpinfo'd it. I get no value for output_buffering and On for register_globals. Turned off register_globals. I think the issue is that it's not reading the $_SESSION variables. I have them in my browser, and every page begins with session_start(); but it's not finding them.
-
Well, even though I just tried it now, since newarticle.php already has it that probably wouldn't make a difference.
-
One of the stupidest mistakes I have ever done For some reason, it still doesn't work! Updated the code: <?php session_start(); if($_GET['status']=="done") { if($_POST['username']=="username" && $_POST['password']=="password") { $_SESSION['loggedin']='true'; $_SESSION['name']="test"; } } ?> I then go to login.php, type in the username/password, and I recieve the usual confirmation: LOGGED IN AS test. But then when I navigate to newarticle.php I get redirected back. Hmm...
-
Hi, I have an issue where my session variables are not saved. Here's my pages are supposed to do check.php, included in all pages contains this: <?php if(!isset($_SESSION['loggedin'])) { header("Location: login.php"); } ?> Which means that if the session variable is not set, it redirects to login.php. login.php contains a username and password box. This is the code: if($_GET['status']=="done") { if($username=="username" && $password=="password") { $_SESSION['loggedin']='true'; $_SESSION['name']="test"; } } ?> (header stuff) <?php if($_GET['status']!="done") { echo" <form action=\"login.php?status=done\" method=\"post\"> Username: <input name=\"username\" type=\"text\" /><br /> Password: <input name=\"password\" type=\"password\" /><br /> <input name=\"login\" type=\"submit\" id=\"login\" value=\"Log In\" /> </form>"; } else if($_GET['status']=="done") { if($_SESSION['loggedin']==true) { echo "LOGGED IN AS ".$_SESSION['name']; } else { echo "INVALID USERNAME OR PASSWORD / TRY AGAIN"; } } ?> Of course, it echoes "LOGGED IN AS test" But when I visit newarticle.php, I get redirected back to login.php. Herés newarticle.php's code (just the top, there's more): <?php session_start(); include ("check.php"); ?> I'm not sure what I'm doing wrong. I've tried putting session_start(); in check.php, but that didn't work either. I'm not sure it's even my fault...
-
I found out that putting the HTML code for the character (such as ) works without messing up. Thanks for your help, I learned something!
-
Thanks. I tried this: /* change character set to utf8 */ if (!mysqli_set_charset($con, "utf8")) { printf("Error loading character set utf8: %s\n", mysqli_error($con)); } else { printf("Current character set: %s\n", mysqli_character_set_name($con)); } to test, and the output was "Error loading character set utf8:" I don't understand.
-
I know my HTML has to be UTF-8. Does that mean I need all my PHP in the body (since the HTML that makes the charset utf-8 is in the head)? Thanks, I think this is the last question!
-
I tried exporting and importing the table. I also went in and redid a row, and it still shows up wrong.
-
Okay, I changed the collation to utf8_unicode_ci. This changes the encoding set to UTF-8, right? For some reason I'm still getting �'s. Is there another way to do it or something?
-
Welp, I've encountered an error this time... Certain characters don't seemed to be displayed when I echo the data in PHP file. For example, the mdash (—) and the a with a tilde (which is necessary for certain places such as São Paulo). These show up as �. Is there any way to get them to show normally? I've tried surrounding them with `'s and putting \'s in front of them, but I can't seem to find out how to get them to work.
-
Thanks so much! I have it working now!
-
Well, I haven't tried anything, because I don't understand :/ I need to echo every single row. Is there an all-inclusive? Or do I echo this? $result = mysql_query("SELECT * FROM articles ORDER BY artnum DESC");
-
I understand how to use echo, but what do I put in there? The whole MySQL statement? Sorry, I'm genuinely confused about this.
-
Hey there, I need some help figuring out how to do something. What I need is a way to recall the whole database in descending order by artnum (the number of each entry). artnum begins at 001 and continues 002 003 and so on. Then it echoes them like this: <div class="big"><a href="newsn.php?art=[iNSERT art_title_url HERE]">[iNSERT art_title HERE]</a></div> [iNSERT art_desc HERE]<br /><br /> I already know how to fill them in, I just don't know how to make it so that I have one for each entry, so it would be like: <div class="big"><a href="newsn.php?art=[iNSERT 002 art_title_url HERE]">[iNSERT 002 art_title HERE]</a></div> [iNSERT 002 art_desc HERE]<br /><br /> <div class="big"><a href="newsn.php?art=[iNSERT 001 art_title_url HERE]">[iNSERT 001 art_title HERE]</a></div> [iNSERT 001 art_desc HERE]<br /><br /> (the 001 and 002 are the artnum numbers) This is what I have so far, but I think I'm wrong: $result = mysql_query("SELECT * FROM articles ORDER BY artnum DESC"); while($row = mysql_fetch_array($result)) { $art_title=$row['art_title']; $art_title_url=$row['art_title_url']; $art_desc=$row['art_desc']; } The main thing about that code is I need a way to echo every piece of information. I'm sorry if you don't understand, it's sort of hard to explain. If you want, post here and I'll try to say it to where you'll understand. My MySQL version is 5.0.91-log